From 4d64e4cd434426234a5c313c151cd79b6afc299e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juha=20Vehvil=C3=A4inen?= Date: Sat, 6 Jul 2002 17:50:18 +0000 Subject: *** empty log message *** svn path=/trunk/Framestein/; revision=27 --- Source/Filez.pas | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 Source/Filez.pas (limited to 'Source/Filez.pas') diff --git a/Source/Filez.pas b/Source/Filez.pas new file mode 100644 index 0000000..1560a77 --- /dev/null +++ b/Source/Filez.pas @@ -0,0 +1,87 @@ +unit Filez; +{$I-} + +interface + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs; + +type + THandleFileEvent = procedure( const SearchRec:TSearchRec; + const FullPath: String ) of object; + // fullpath contains filepath+filename + + TScanDir = class(TComponent) + private + { Private declarations } + FOnHandleFile : THandleFileEvent; + protected + { Protected declarations } + public + { Public declarations } + procedure Scan( const Path : String ); + constructor Create( AOwner:TComponent ); override; + published + { Published declarations } + property OnHandleFile : THandleFileEvent read FOnHandleFile write FOnHandleFile; + end; + + function FileSizeByName( const FileName:String ):Longint; + +procedure Register; + +implementation + +uses + Strz; + +function FileSizeByName( const FileName:String ):Longint; +var + F:file of Byte; +begin + Result := 0; + AssignFile(F, FileName); + Reset(F); + if IoResult<>0 then Exit; + Result := FileSize(F); + Close(F); +end; + +constructor TScanDir.Create( AOwner:TComponent ); +begin + inherited Create( AOwner ); + + FOnHandleFile := nil; +end; + +procedure TScanDir.Scan( const Path : String ); +var + SearchRec : TSearchRec; + Result : Integer; + S : String; +begin + if not Assigned(FOnHandleFile) then + Exit; + + S := VerifyBackSlash(Path); + Result := FindFirst( S+'*.*', faAnyFile, SearchRec); + if Result=0 then + repeat + if (SearchRec.Name='.') or (SearchRec.Name='..') then + Continue; + + FOnHandleFile( SearchRec, + S+SearchRec.Name ); + + if SearchRec.Attr and faDirectory>0 then + Scan( S+SearchRec.Name ); + until FindNext(SearchRec)<>0; +end; + +procedure Register; +begin + RegisterComponents('Labrz', [TScanDir]); +end; + +end. + -- cgit v1.2.1