| [17] | 1 | unit ACLFindFunctions;
 | 
|---|
 | 2 | // Replacements/wrappers for file find functions
 | 
|---|
 | 3 | // The main problem is that I have had problems
 | 
|---|
 | 4 | // with the Delphi functions.
 | 
|---|
 | 5 | interface
 | 
|---|
 | 6 | 
 | 
|---|
 | 7 | uses
 | 
|---|
 | 8 |   SysUtils;
 | 
|---|
 | 9 | 
 | 
|---|
 | 10 | type
 | 
|---|
 | 11 |   TSearchData = SysUtils.TSearchRec;
 | 
|---|
 | 12 | 
 | 
|---|
 | 13 | function MyFindFirst( const Path: string;
 | 
|---|
 | 14 |                       var F: TSearchData ): integer;
 | 
|---|
 | 15 | function MyFindNext( var F: TSearchData ): Integer;
 | 
|---|
 | 16 | procedure MyFindClose(var F: TSearchData);
 | 
|---|
 | 17 | 
 | 
|---|
 | 18 | implementation
 | 
|---|
 | 19 | 
 | 
|---|
 | 20 | {$ifdef win32}
 | 
|---|
 | 21 | uses
 | 
|---|
 | 22 |   Windows;
 | 
|---|
 | 23 |   
 | 
|---|
 | 24 | procedure TranslateFindData( var F: TSearchData );
 | 
|---|
 | 25 | var
 | 
|---|
 | 26 |   LocalFileTime: TFileTime;
 | 
|---|
 | 27 | begin
 | 
|---|
 | 28 |   with F do
 | 
|---|
 | 29 |   begin
 | 
|---|
 | 30 |     FileTimeToLocalFileTime( FindData.ftLastWriteTime,
 | 
|---|
 | 31 |                              LocalFileTime );
 | 
|---|
 | 32 |     FileTimeToDosDateTime( LocalFileTime,
 | 
|---|
 | 33 |                            LongRec(Time).Hi,
 | 
|---|
 | 34 |                            LongRec(Time).Lo );
 | 
|---|
 | 35 |     Size := FindData.nFileSizeLow;
 | 
|---|
 | 36 |     Attr := FindData.dwFileAttributes;
 | 
|---|
 | 37 |     Name := FindData.cFileName;
 | 
|---|
 | 38 |   end;
 | 
|---|
 | 39 | end;
 | 
|---|
 | 40 | 
 | 
|---|
 | 41 | function MyFindFirst( const Path: string;
 | 
|---|
 | 42 |                       var F: TSearchData ): integer;
 | 
|---|
 | 43 | begin
 | 
|---|
 | 44 |   F.FindHandle := FindFirstFile( PChar( Path ), F.FindData );
 | 
|---|
 | 45 | 
 | 
|---|
 | 46 |   if F.FindHandle = INVALID_HANDLE_VALUE then
 | 
|---|
 | 47 |     Result:= ERROR_NO_MORE_FILES
 | 
|---|
 | 48 |   else
 | 
|---|
 | 49 |   begin
 | 
|---|
 | 50 |     TranslateFindData( F );
 | 
|---|
 | 51 |     Result:= 0;
 | 
|---|
 | 52 |   end;
 | 
|---|
 | 53 | end;
 | 
|---|
 | 54 | 
 | 
|---|
 | 55 | function MyFindNext( var F: TSearchData ): Integer;
 | 
|---|
 | 56 | begin
 | 
|---|
 | 57 |   if FindNextFile( F.FindHandle, F.FindData ) then
 | 
|---|
 | 58 |   begin
 | 
|---|
 | 59 |     Result:= 0;
 | 
|---|
 | 60 |     TranslateFindData( F );
 | 
|---|
 | 61 |   end
 | 
|---|
 | 62 |   else
 | 
|---|
 | 63 |     Result:= 1;
 | 
|---|
 | 64 | end;
 | 
|---|
 | 65 | 
 | 
|---|
 | 66 | procedure MyFindClose(var F: TSearchData);
 | 
|---|
 | 67 | begin
 | 
|---|
 | 68 |   Windows.FindClose( F.FindHandle );
 | 
|---|
 | 69 | end;
 | 
|---|
 | 70 | {$else}
 | 
|---|
 | 71 | // OS/2 versions: just pass thru to Sibyl versions.
 | 
|---|
 | 72 | function MyFindFirst( const Path: string;
 | 
|---|
 | 73 |                       var F: TSearchData ): integer;
 | 
|---|
 | 74 | begin
 | 
|---|
 | 75 |   Result:= SysUtils.FIndFirst( Path, faAnyFile, F );
 | 
|---|
 | 76 | end;
 | 
|---|
 | 77 | 
 | 
|---|
 | 78 | function MyFindNext( var F: TSearchData ): Integer;
 | 
|---|
 | 79 | begin
 | 
|---|
 | 80 |   Result:= SysUtils.FindNext( F );
 | 
|---|
 | 81 | end;
 | 
|---|
 | 82 | 
 | 
|---|
 | 83 | procedure MyFindClose(var F: TSearchData);
 | 
|---|
 | 84 | begin
 | 
|---|
 | 85 |   SysUtils.FindClose( F );
 | 
|---|
 | 86 | end;
 | 
|---|
 | 87 | {$endif}
 | 
|---|
 | 88 | 
 | 
|---|
 | 89 | 
 | 
|---|
 | 90 | end.
 | 
|---|