sysutils.pp 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. {
  2. $Id$
  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
  6. Sysutils unit for linux
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. **********************************************************************}
  13. unit sysutils;
  14. interface
  15. {$MODE objfpc}
  16. { force ansistrings }
  17. {$H+}
  18. uses
  19. beos;
  20. { Include platform independent interface part }
  21. {$i sysutilh.inc}
  22. implementation
  23. { Include platform independent implementation part }
  24. {$i sysutils.inc}
  25. {****************************************************************************
  26. File Functions
  27. ****************************************************************************}
  28. Function FileOpen (Const FileName : string; Mode : Integer) : Longint;
  29. BEGIN
  30. end;
  31. Function FileCreate (Const FileName : String) : Longint;
  32. begin
  33. end;
  34. Function FileRead (Handle : Longint; Var Buffer; Count : longint) : Longint;
  35. begin
  36. end;
  37. Function FileWrite (Handle : Longint; const Buffer; Count : Longint) : Longint;
  38. begin
  39. end;
  40. Function FileSeek (Handle,FOffset,Origin : Longint) : Longint;
  41. begin
  42. end;
  43. Procedure FileClose (Handle : Longint);
  44. begin
  45. end;
  46. Function FileTruncate (Handle,Size: Longint) : boolean;
  47. begin
  48. end;
  49. Function FileAge (Const FileName : String): Longint;
  50. begin
  51. end;
  52. Function FileExists (Const FileName : String) : Boolean;
  53. begin
  54. end;
  55. Function FindFirst (Const Path : String; Attr : Longint; Var Rslt : TSearchRec) : Longint;
  56. begin
  57. end;
  58. Function FindNext (Var Rslt : TSearchRec) : Longint;
  59. begin
  60. end;
  61. Procedure FindClose (Var F : TSearchrec);
  62. begin
  63. end;
  64. Function FileGetDate (Handle : Longint) : Longint;
  65. begin
  66. end;
  67. Function FileSetDate (Handle,Age : Longint) : Longint;
  68. begin
  69. end;
  70. Function FileGetAttr (Const FileName : String) : Longint;
  71. begin
  72. end;
  73. Function FileSetAttr (Const Filename : String; Attr: longint) : Longint;
  74. begin
  75. end;
  76. Function DeleteFile (Const FileName : String) : Boolean;
  77. begin
  78. end;
  79. Function RenameFile (Const OldName, NewName : String) : Boolean;
  80. begin
  81. end;
  82. Function FileSearch (Const Name, DirList : String) : String;
  83. begin
  84. end;
  85. {****************************************************************************
  86. Disk Functions
  87. ****************************************************************************}
  88. Function DiskFree(Drive: Byte): int64;
  89. Begin
  90. End;
  91. Function DiskSize(Drive: Byte): int64;
  92. Begin
  93. End;
  94. Function GetCurrentDir : String;
  95. begin
  96. GetDir(0,Result);
  97. end;
  98. Function SetCurrentDir (Const NewDir : String) : Boolean;
  99. begin
  100. {$I-}
  101. ChDir(NewDir);
  102. {$I+}
  103. result := (IOResult = 0);
  104. end;
  105. Function CreateDir (Const NewDir : String) : Boolean;
  106. begin
  107. {$I-}
  108. MkDir(NewDir);
  109. {$I+}
  110. result := (IOResult = 0);
  111. end;
  112. Function RemoveDir (Const Dir : String) : Boolean;
  113. begin
  114. {$I-}
  115. RmDir(Dir);
  116. {$I+}
  117. result := (IOResult = 0);
  118. end;
  119. function DirectoryExists (const Directory: string): boolean;
  120. begin
  121. end;
  122. {****************************************************************************
  123. Misc Functions
  124. ****************************************************************************}
  125. procedure Beep;
  126. begin
  127. end;
  128. {****************************************************************************
  129. Locale Functions
  130. ****************************************************************************}
  131. Procedure GetLocalTime(var SystemTime: TSystemTime);
  132. begin
  133. end ;
  134. Procedure InitAnsi;
  135. Var
  136. i : longint;
  137. begin
  138. { Fill table entries 0 to 127 }
  139. for i := 0 to 96 do
  140. UpperCaseTable[i] := chr(i);
  141. for i := 97 to 122 do
  142. UpperCaseTable[i] := chr(i - 32);
  143. for i := 123 to 191 do
  144. UpperCaseTable[i] := chr(i);
  145. Move (CPISO88591UCT,UpperCaseTable[192],SizeOf(CPISO88591UCT));
  146. for i := 0 to 64 do
  147. LowerCaseTable[i] := chr(i);
  148. for i := 65 to 90 do
  149. LowerCaseTable[i] := chr(i + 32);
  150. for i := 91 to 191 do
  151. LowerCaseTable[i] := chr(i);
  152. Move (CPISO88591LCT,UpperCaseTable[192],SizeOf(CPISO88591UCT));
  153. end;
  154. Procedure InitInternational;
  155. begin
  156. InitAnsi;
  157. end;
  158. function SysErrorMessage(ErrorCode: Integer): String;
  159. begin
  160. Str(Errorcode,Result);
  161. Result:='Error '+Result;
  162. end;
  163. {****************************************************************************
  164. OS utility functions
  165. ****************************************************************************}
  166. Function GetEnvironmentVariable(Const EnvVar : String) : String;
  167. begin
  168. Result:=StrPas(beos.Getenv(PChar(EnvVar)));
  169. end;
  170. Function GetEnvironmentVariableCount : Integer;
  171. begin
  172. Result:=FPCCountEnvVar(EnvP);
  173. end;
  174. Function GetEnvironmentString(Index : Integer) : String;
  175. begin
  176. Result:=FPCGetEnvStrFromP(Envp,Index);
  177. end;
  178. function ExecuteProcess(Const Path: AnsiString; Const ComLine: AnsiString):integer;
  179. var
  180. e : EOSError;
  181. CommandLine: AnsiString;
  182. begin
  183. dos.exec(path,comline);
  184. if (Dos.DosError <> 0) then
  185. begin
  186. if ComLine <> '' then
  187. CommandLine := Path + ' ' + ComLine
  188. else
  189. CommandLine := Path;
  190. e:=EOSError.CreateFmt(SExecuteProcessFailed,[CommandLine,Dos.DosError]);
  191. e.ErrorCode:=Dos.DosError;
  192. raise e;
  193. end;
  194. Result := DosExitCode;
  195. end;
  196. function ExecuteProcess (const Path: AnsiString;
  197. const ComLine: array of AnsiString): integer;
  198. var
  199. CommandLine: AnsiString;
  200. I: integer;
  201. begin
  202. Commandline := '';
  203. for I := 0 to High (ComLine) do
  204. if Pos (' ', ComLine [I]) <> 0 then
  205. CommandLine := CommandLine + ' ' + '"' + ComLine [I] + '"'
  206. else
  207. CommandLine := CommandLine + ' ' + Comline [I];
  208. ExecuteProcess := ExecuteProcess (Path, CommandLine);
  209. end;
  210. {****************************************************************************
  211. Initialization code
  212. ****************************************************************************}
  213. Initialization
  214. InitExceptions; { Initialize exceptions. OS independent }
  215. InitInternational; { Initialize internationalization settings }
  216. Finalization
  217. OutOfMemory.Free;
  218. InValidPointer.Free;
  219. end.
  220. {
  221. $Log$
  222. Revision 1.6 2004-12-11 11:32:44 michael
  223. + Added GetEnvironmentVariableCount and GetEnvironmentString calls
  224. Revision 1.5 2004/02/15 21:36:10 hajny
  225. * overloaded ExecuteProcess added, EnvStr param changed to longint
  226. Revision 1.4 2004/01/20 23:12:49 hajny
  227. * ExecuteProcess fixes, ProcessID and ThreadID added
  228. Revision 1.3 2003/03/29 15:16:26 hajny
  229. * dummy DirectoryExists added
  230. Revision 1.2 2002/09/07 16:01:27 peter
  231. * old logs removed and tabs fixed
  232. }