|
Post by Jon Springs on Jul 10, 2008 20:20:45 GMT -5
Hey Kevin,
Long time no type.
As the subject suggests, the FName parameter is blank in the OnStartUnzip event. Searched the source, but could not find the code to fix it.
Help?
Thanks,
-----Jon-----
|
|
|
Post by Kevin on Jul 11, 2008 18:14:01 GMT -5
Hi Jon,
I am not seeing that behavior. What version of VCLZip are you using?
Kevin
|
|
|
Post by Jon Springs on Jul 11, 2008 20:00:52 GMT -5
Kevin,
Using 3.10
This is in a console application if that would matter.
Here's the code:
program Cusip;
{$APPTYPE CONSOLE} {$Define NOFORMS}
uses ExceptionLog, Windows, Classes, Crt32, SysUtils, Messages, VclUnZip;
type { We use TConsoleApplication class ( actually a component ) to encapsulate all the work to be done. This is easier because TFtpCli is event driven and need methods ( that is procedure of object ) to handle events. } TConsoleApplication = class( TComponent ) protected zipFile : TVCLUnZip; procedure EndUnZip( Sender : TObject; FileIndex : Integer; FName : String ); procedure FilePercentDone( Sender : TObject; Percent : Integer ); procedure UnZipComplete( Sender : TObject; FileCount : Integer ); procedure StartUnZip( Sender : TObject; FileIndex : Integer; var FName : String; var Skip : Boolean ); procedure GetNextBuffer( Sender : TObject; var Buffer : PChar; FName : String; AmountUsed : LongInt; BufferNum : Integer; var Quit : Boolean); procedure MessageLoop; public constructor Create( AOwner: TComponent ); override; destructor Destroy; override; procedure Execute; end;
var i, rc, x, y : integer; fileName, textLine : string; buffer : pchar; consoleApp : TConsoleApplication; outputFile : text;
procedure TConsoleApplication.MessageLoop;
var MsgRec : TMsg;
begin // If GetMessage retrieves the WM_QUIT, the return value is FALSE and // the message loop is broken. while GetMessage( MsgRec, 0, 0, 0 ) do begin TranslateMessage( MsgRec ); DispatchMessage( MsgRec ) end; end;
procedure TConsoleApplication.EndUnZip( Sender : TObject; FileIndex : Integer; FName : String );
begin WriteLn; end;
procedure TConsoleApplication.FilePercentDone( Sender : TObject; Percent: Integer );
begin GotoXY( x, y ); Write( Percent ); end;
procedure TConsoleApplication.GetNextBuffer( Sender : TObject; var Buffer : PChar; FName : String; AmountUsed : LongInt; BufferNum : Integer; var Quit : Boolean);
var textLine : string;
begin; textLine := StrPas( buffer ); SetLength( textLine, 80 ); if Copy( textLine, 2, 9 ) = '033161WE6' then WriteLn( outputFile, fName, ' ', textLine ); end;
procedure TConsoleApplication.StartUnZip( Sender : TObject; FileIndex : Integer; var FName : String; var Skip : Boolean );
begin Write( 'Processing ', zipFile.fileName[ fileIndex ], ' ' ); x := WhereX; y := WhereY; end;
procedure TConsoleApplication.UnZipComplete( Sender : TObject; FileCount : Integer );
begin // PostMessage( 0, WM_QUIT, 0, 0 ); end;
procedure TConsoleApplication.Execute;
var ok : boolean; i : integer; hold, zipName : string; fileList : TStringList;
begin zipFile := TVCLUnZip.Create( Self ); zipFile.zipName := 'portmain.zip'; zipFile.ReadZip; zipFile.BufferLength := 82; zipFile.OnEndUnZip := EndUnZip; zipFile.OnFilePercentDone := FilePercentDone; zipFile.OnUnZipComplete := UnZipComplete; zipFile.OnStartUnZip := StartUnZip; zipFile.OnGetNextBuffer := GetNextBuffer; zipFile.OnUnZipComplete := UnZipComplete; GetMem( buffer, 82 ); AssignFile( outputFile, 'output.txt' ); Rewrite( outputFile ); fileList := TStringList.Create; fileList.Sorted := True; for i := 0 to Pred( zipFile.Count ) do begin fileName := zipFile.fileName[ i ]; if Copy( fileName, 15, 8 ) > '20071231' then fileList.Add( fileName ); end; for i := 0 to Pred( fileList.Count ) do zipFile.UnZipToBuffer( buffer, fileList[ i ] ); zipFile.ClearZip; zipFile.Free; CloseFile( outputFile ); end;
constructor TConsoleApplication.Create( AOwner: TComponent );
begin inherited Create( AOwner ); end;
destructor TConsoleApplication.Destroy;
begin inherited Destroy; end;
begin WriteLn( 'CUSIP Version 1.0' );
consoleApp := TConsoleApplication.Create( nil ); try consoleApp.Execute; finally consoleApp.Destroy; end; end.
The files in the zip are 80 char text lines;
|
|