source: branches/2.19_branch/Library/ACLFindFunctions.pas@ 324

Last change on this file since 324 was 17, checked in by RBRi, 19 years ago

+ Library

  • Property svn:eol-style set to native
File size: 1.9 KB
Line 
1unit ACLFindFunctions;
2// Replacements/wrappers for file find functions
3// The main problem is that I have had problems
4// with the Delphi functions.
5interface
6
7uses
8 SysUtils;
9
10type
11 TSearchData = SysUtils.TSearchRec;
12
13function MyFindFirst( const Path: string;
14 var F: TSearchData ): integer;
15function MyFindNext( var F: TSearchData ): Integer;
16procedure MyFindClose(var F: TSearchData);
17
18implementation
19
20{$ifdef win32}
21uses
22 Windows;
23
24procedure TranslateFindData( var F: TSearchData );
25var
26 LocalFileTime: TFileTime;
27begin
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;
39end;
40
41function MyFindFirst( const Path: string;
42 var F: TSearchData ): integer;
43begin
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;
53end;
54
55function MyFindNext( var F: TSearchData ): Integer;
56begin
57 if FindNextFile( F.FindHandle, F.FindData ) then
58 begin
59 Result:= 0;
60 TranslateFindData( F );
61 end
62 else
63 Result:= 1;
64end;
65
66procedure MyFindClose(var F: TSearchData);
67begin
68 Windows.FindClose( F.FindHandle );
69end;
70{$else}
71// OS/2 versions: just pass thru to Sibyl versions.
72function MyFindFirst( const Path: string;
73 var F: TSearchData ): integer;
74begin
75 Result:= SysUtils.FIndFirst( Path, faAnyFile, F );
76end;
77
78function MyFindNext( var F: TSearchData ): Integer;
79begin
80 Result:= SysUtils.FindNext( F );
81end;
82
83procedure MyFindClose(var F: TSearchData);
84begin
85 SysUtils.FindClose( F );
86end;
87{$endif}
88
89
90end.
Note: See TracBrowser for help on using the repository browser.