2
$Id: sysutils.pp,v 1.9 2004/02/15 21:26:37 hajny Exp $
3
This file is part of the Free Pascal run time library.
4
Copyright (c) 1999-2000 by Florian Klaempfl
5
member of the Free Pascal development team
9
See the file COPYING.FPC, included in this distribution,
10
for details about the copyright.
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
**********************************************************************}
28
{ Include platform independent interface part }
37
{ Include platform independent implementation part }
41
{****************************************************************************
43
****************************************************************************}
45
Function FileOpen (Const FileName : string; Mode : Integer) : Longint;
50
Function FileCreate (Const FileName : String) : longint;
54
Function FileCreate (Const FileName : String;Mode:longint) : longint;
59
Function FileRead (Handle : Longint; Var Buffer; Count : longint) : Longint;
64
Function FileWrite (Handle : Longint; const Buffer; Count : Longint) : Longint;
69
Function FileSeek (Handle,FOffset,Origin : longint) : longint;
73
Function FileSeek (Handle:longint;FOffset,Origin : int64) : int64;
78
Procedure FileClose (Handle : Longint);
83
Function FileTruncate (Handle,Size: Longint) : boolean;
88
Function FileAge (Const FileName : String): Longint;
93
Function FileExists (Const FileName : String) : Boolean;
98
Function FindFirst (Const Path : String; Attr : Longint; Var Rslt : TSearchRec) : Longint;
103
Function FindNext (Var Rslt : TSearchRec) : Longint;
108
Procedure FindClose (Var F : TSearchrec);
113
Function FileGetDate (Handle : Longint) : Longint;
118
Function FileSetDate (Handle,Age : Longint) : Longint;
123
Function FileGetAttr (Const FileName : String) : Longint;
128
Function FileSetAttr (Const Filename : String; Attr: longint) : Longint;
133
Function DeleteFile (Const FileName : String) : Boolean;
138
Function RenameFile (Const OldName, NewName : String) : Boolean;
142
{****************************************************************************
144
****************************************************************************}
146
Function DiskFree(Drive: Byte): int64;
152
Function DiskSize(Drive: Byte): int64;
157
Function GetCurrentDir : String;
163
Function SetCurrentDir (Const NewDir : String) : Boolean;
168
result := (IOResult = 0);
172
Function CreateDir (Const NewDir : String) : Boolean;
177
result := (IOResult = 0);
181
Function RemoveDir (Const Dir : String) : Boolean;
186
result := (IOResult = 0);
190
function DirectoryExists (const Directory: string): boolean;
195
{****************************************************************************
197
****************************************************************************}
204
{****************************************************************************
206
****************************************************************************}
208
Procedure GetLocalTime(var SystemTime: TSystemTime);
217
{ Fill table entries 0 to 127 }
219
UpperCaseTable[i] := chr(i);
220
for i := 97 to 122 do
221
UpperCaseTable[i] := chr(i - 32);
222
for i := 123 to 191 do
223
UpperCaseTable[i] := chr(i);
224
Move (CPISO88591UCT,UpperCaseTable[192],SizeOf(CPISO88591UCT));
227
LowerCaseTable[i] := chr(i);
229
LowerCaseTable[i] := chr(i + 32);
230
for i := 91 to 191 do
231
LowerCaseTable[i] := chr(i);
232
Move (CPISO88591LCT,UpperCaseTable[192],SizeOf(CPISO88591UCT));
236
Procedure InitInternational;
241
function SysErrorMessage(ErrorCode: Integer): String;
244
Str(Errorcode,Result);
245
Result:='Error '+Result;
248
{****************************************************************************
250
****************************************************************************}
252
Function GetEnvironmentVariable(Const EnvVar : String) : String;
255
Result:=StrPas(beos.Getenv(PChar(EnvVar)));
259
function ExecuteProcess (const Path: AnsiString; const ComLine: AnsiString):
263
CommandLine: AnsiString;
266
{ always surround the name of the application by quotes
267
so that long filenames will always be accepted. But don't
268
do it if there are already double quotes!
270
if pos('"',path)=0 then
271
CommandLine:='"'+path+'"'
274
if ComLine <> '' then
275
CommandLine := Commandline + ' ' + ComLine;
276
ExecuteProcess := beos.shell (CommandLine);
280
function ExecuteProcess (const Path: AnsiString;
281
const ComLine: array of AnsiString): integer;
283
{$WARNING Should be probably changed according to the Unix version}
285
CommandLine: AnsiString;
290
for I := 0 to High (ComLine) do
291
if Pos (' ', ComLine [I]) <> 0 then
292
CommandLine := CommandLine + ' ' + '"' + ComLine [I] + '"'
294
CommandLine := CommandLine + ' ' + Comline [I];
295
ExecuteProcess := ExecuteProcess (Path, CommandLine);
300
{****************************************************************************
302
****************************************************************************}
305
InitExceptions; { Initialize exceptions. OS independent }
306
InitInternational; { Initialize internationalization settings }
311
$Log: sysutils.pp,v $
312
Revision 1.9 2004/02/15 21:26:37 hajny
313
* overloaded ExecuteProcess added, EnvStr param changed to longint
315
Revision 1.8 2004/01/20 23:09:14 hajny
316
* ExecuteProcess fixes, ProcessID and ThreadID added
318
Revision 1.7 2003/11/26 20:00:19 florian
319
* error handling for Variants improved
321
Revision 1.5 2003/03/29 15:16:26 hajny
322
* dummy DirectoryExists added
324
Revision 1.4 2003/01/08 21:56:54 marco
325
* small fixes to prototypes to compile it
327
Revision 1.3 2002/09/07 16:01:17 peter
328
* old logs removed and tabs fixed
b'\\ No newline at end of file'