blob: 5435df7490241b2120340a0ee0ed89fb0de462f3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
{
This file is part of the Free Pascal run time library.
Copyright (c) 1999-2000 by the Free Pascal development team
File utility calls
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**********************************************************************}
Type
// Some operating systems need FindHandle to be a Pointer
{$if defined(unix) or defined(msdos) or defined(hasamiga) or defined(atari) or defined(win16)}
{$define FINDHANDLE_IS_POINTER}
{$endif}
// Some operating systems need extra find data.
{$if defined(Win32) or defined(WinCE) or defined(Win64)}
{$define USEFINDDATA}
TFindData = TWin32FindDataW;
{$endif}
{$ifdef netware_clib}
TFindData = TNetwareFindData;
{$define USEFINDDATA}
{$endif}
{$ifdef netware_libc}
TFindData = TNetwareLibcFindData;
{$define USEFINDDATA}
{$endif}
{$ifdef MacOS}
TFindData = TMacOSFindData;
{$define USEFINDDATA}
{$endif}
{$ifdef nativent}
TFindData = TNativeNTFindData;
{$define USEFINDDATA}
{$endif}
// The actual unicode search record
TUnicodeSearchRec = Record
Time : Longint;
Size : Int64;
Attr : Longint;
Name : UnicodeString;
ExcludeAttr : Longint;
FindHandle : {$ifdef FINDHANDLE_IS_POINTER}Pointer{$else}THandle{$endif};
{$ifdef unix}
Mode : TMode;
{$endif unix}
{$ifdef USEFINDDATA}
FindData : TFindData;
{$endif}
private
function GetTimeStamp: TDateTime;
public
property TimeStamp: TDateTime read GetTimeStamp;
end;
TRawbyteSearchRec = Record
Time : Longint;
Size : Int64;
Attr : Longint;
Name : RawByteString;
ExcludeAttr : Longint;
FindHandle : {$ifdef FINDHANDLE_IS_POINTER}Pointer{$else}THandle{$endif};
{$ifdef unix}
Mode : TMode;
{$endif unix}
{$IFDEF USEFINDDATA}
FindData : TFindData;
{$ENDIF}
private
function GetTimeStamp: TDateTime;
public
property TimeStamp: TDateTime read GetTimeStamp;
end;
{$IFDEF FPC_UNICODE_RTL}
TSearchRec = TUnicodeSearchRec;
{$ELSE}
TSearchRec = TRawbyteSearchRec;
{$ENDIF}
Const
{ File attributes }
faReadOnly = $00000001;
faHidden = $00000002 platform;
faSysFile = $00000004 platform;
faVolumeId = $00000008 platform deprecated;
faDirectory = $00000010;
faArchive = $00000020;
faNormal = $00000080;
faTemporary = $00000100 platform;
faSymLink = $00000400 platform;
faCompressed = $00000800 platform;
faEncrypted = $00004000 platform;
faVirtual = $00010000 platform;
faAnyFile = $000001FF;
{ File open modes }
fmOpenRead = $0000;
fmOpenWrite = $0001;
fmOpenReadWrite = $0002;
{ Share modes}
fmShareCompat = $0000;
fmShareExclusive = $0010;
fmShareDenyWrite = $0020;
fmShareDenyRead = $0030;
fmShareDenyNone = $0040;
{ File seek origins }
fsFromBeginning = 0;
fsFromCurrent = 1;
fsFromEnd = 2;
{ File errors }
feInvalidHandle : THandle = THandle(-1); //return value on FileOpen error
Type
TFileSearchOption = (sfoImplicitCurrentDir,sfoStripQuotes);
TFileSearchOptions = set of TFileSearchOption;
Function FileOpen (Const FileName : unicodestring; Mode : Integer) : THandle;
Function FileCreate (Const FileName : UnicodeString) : THandle;
Function FileCreate (Const FileName : UnicodeString; Rights : Integer) : THandle;
Function FileCreate (Const FileName : UnicodeString; ShareMode : Integer; Rights : Integer) : THandle;
{$IFNDEF FPUNONE}
Function FileAge (Const FileName : UnicodeString): Longint;
{$ENDIF}
Function FileExists (Const FileName : UnicodeString) : Boolean;
Function DirectoryExists (Const Directory : UnicodeString) : Boolean;
Function FileSetDate (Const FileName : UnicodeString;Age : Longint) : Longint;
Function FileGetAttr (Const FileName : UnicodeString) : Longint;
Function FileSetAttr (Const Filename : UnicodeString; Attr: longint) : Longint;
Function DeleteFile (Const FileName : UnicodeString) : Boolean;
Function RenameFile (Const OldName, NewName : UnicodeString) : Boolean;
Function FindFirst (Const Path : UnicodeString; Attr : Longint; out Rslt : TUnicodeSearchRec) : Longint;
Function FindNext (Var Rslt : TUnicodeSearchRec) : Longint;
Procedure FindClose (Var F : TUnicodeSearchrec);
Function FileSearch (Const Name, DirList : UnicodeString; Options : TFileSearchoptions = [sfoImplicitCurrentDir]) : UnicodeString;
Function FileSearch (Const Name, DirList : UnicodeString; ImplicitCurrentDir : Boolean) : UnicodeString;
Function ExeSearch (Const Name : UnicodeString; Const DirList : UnicodeString = '') : UnicodeString;
Function FileIsReadOnly(const FileName : UnicodeString): Boolean;
function FileAge(const FileName: UnicodeString; out FileDateTime: TDateTime; FollowLink: Boolean = True): Boolean;
Function FileOpen (Const FileName : RawByteString; Mode : Integer) : THandle;
Function FileCreate (Const FileName : RawByteString) : THandle;
Function FileCreate (Const FileName : RawByteString; Rights : Integer) : THandle;
Function FileCreate (Const FileName : RawByteString; ShareMode : Integer; Rights : Integer) : THandle;
Function FileExists (Const FileName : RawByteString) : Boolean;
Function DirectoryExists (Const Directory : RawByteString) : Boolean;
Function FileSetDate (Const FileName : RawByteString;Age : Longint) : Longint;
Function FileGetAttr (Const FileName : RawByteString) : Longint;
Function FileSetAttr (Const Filename : RawByteString; Attr: longint) : Longint;
Function DeleteFile (Const FileName : RawByteString) : Boolean;
Function RenameFile (Const OldName, NewName : RawByteString) : Boolean;
Function FindFirst (Const Path : RawByteString; Attr : Longint; out Rslt : TRawByteSearchRec) : Longint;
Function FileSearch (Const Name, DirList : RawByteString; Options : TFileSearchoptions = [sfoImplicitCurrentDir]) : RawByteString;
Function FileSearch (Const Name, DirList : RawByteString; ImplicitCurrentDir : Boolean) : RawByteString;
Function ExeSearch (Const Name : RawByteString; Const DirList : RawByteString = '') : RawByteString;
Function FileIsReadOnly(const FileName: RawByteString): Boolean;
function FileAge(const FileName: RawByteString; out FileDateTime: TDateTime; FollowLink: Boolean = True): Boolean;
{$ifndef FPUNONE}
Function FileAge (Const FileName : RawByteString): Longint;
{$endif}
Function FileRead (Handle : THandle; out Buffer; Count : longint) : Longint;
Function FileWrite (Handle : THandle; const Buffer; Count : Longint) : Longint;
Function FileSeek (Handle : THandle; FOffset, Origin: Longint) : Longint;
Function FileSeek (Handle : THandle; FOffset: Int64; Origin: Longint) : Int64;
function FileFlush(Handle: THandle): Boolean;
Procedure FileClose (Handle : THandle);
Function FileTruncate (Handle : THandle;Size: Int64) : boolean;
Function FindNext (Var Rslt : TRawByteSearchRec) : Longint;
Procedure FindClose (Var F : TRawByteSearchrec);
Function FileGetDate (Handle : THandle) : Longint;
Function FileSetDate (Handle : THandle;Age : Longint) : Longint;
Function GetFileHandle(var f : File):THandle;
Function GetFileHandle(var f : Text):THandle;
|