sysutils.pp 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2000 by Florian Klaempfl
  4. member of the Free Pascal development team
  5. Sysutils unit for BeOS
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. unit sysutils;
  13. interface
  14. {$MODE objfpc}
  15. { force ansistrings }
  16. {$H+}
  17. uses
  18. beos,
  19. dos;
  20. { Include platform independent interface part }
  21. {$i sysutilh.inc}
  22. implementation
  23. uses
  24. sysconst;
  25. (* Potentially needed FPC_FEXPAND_* defines should be defined here. *)
  26. { Include platform independent implementation part }
  27. {$i sysutils.inc}
  28. {****************************************************************************
  29. File Functions
  30. ****************************************************************************}
  31. Function FileOpen (Const FileName : string; Mode : Integer) : Longint;
  32. BEGIN
  33. end;
  34. Function FileCreate (Const FileName : String) : longint;
  35. begin
  36. end;
  37. Function FileCreate (Const FileName : String;Mode:longint) : longint;
  38. begin
  39. end;
  40. Function FileRead (Handle : Longint; Var Buffer; Count : longint) : Longint;
  41. begin
  42. end;
  43. Function FileWrite (Handle : Longint; const Buffer; Count : Longint) : Longint;
  44. begin
  45. end;
  46. Function FileSeek (Handle,FOffset,Origin : longint) : longint;
  47. begin
  48. end;
  49. Function FileSeek (Handle:longint;FOffset: Int64; Origin: Longint) : int64;
  50. begin
  51. end;
  52. Procedure FileClose (Handle : Longint);
  53. begin
  54. end;
  55. Function FileTruncate (Handle: longint;Size: Int64) : boolean;
  56. begin
  57. end;
  58. Function FileAge (Const FileName : String): Longint;
  59. begin
  60. end;
  61. Function FileExists (Const FileName : String) : Boolean;
  62. begin
  63. end;
  64. Function FindFirst (Const Path : String; Attr : Longint; out Rslt : TSearchRec) : Longint;
  65. begin
  66. end;
  67. Function FindNext (Var Rslt : TSearchRec) : Longint;
  68. begin
  69. end;
  70. Procedure FindClose (Var F : TSearchrec);
  71. begin
  72. end;
  73. Function FileGetDate (Handle : Longint) : Longint;
  74. begin
  75. end;
  76. Function FileSetDate (Handle,Age : Longint) : Longint;
  77. begin
  78. end;
  79. Function FileGetAttr (Const FileName : String) : Longint;
  80. begin
  81. end;
  82. Function FileSetAttr (Const Filename : String; Attr: longint) : Longint;
  83. begin
  84. end;
  85. Function DeleteFile (Const FileName : String) : Boolean;
  86. begin
  87. end;
  88. Function RenameFile (Const OldName, NewName : String) : Boolean;
  89. begin
  90. end;
  91. {****************************************************************************
  92. Disk Functions
  93. ****************************************************************************}
  94. Function DiskFree(Drive: Byte): int64;
  95. Begin
  96. End;
  97. Function DiskSize(Drive: Byte): int64;
  98. Begin
  99. End;
  100. Function GetCurrentDir : String;
  101. begin
  102. GetDir(0,Result);
  103. end;
  104. Function SetCurrentDir (Const NewDir : String) : Boolean;
  105. begin
  106. {$I-}
  107. ChDir(NewDir);
  108. {$I+}
  109. result := (IOResult = 0);
  110. end;
  111. Function CreateDir (Const NewDir : String) : Boolean;
  112. begin
  113. {$I-}
  114. MkDir(NewDir);
  115. {$I+}
  116. result := (IOResult = 0);
  117. end;
  118. Function RemoveDir (Const Dir : String) : Boolean;
  119. begin
  120. {$I-}
  121. RmDir(Dir);
  122. {$I+}
  123. result := (IOResult = 0);
  124. end;
  125. function DirectoryExists (const Directory: string): boolean;
  126. begin
  127. end;
  128. {****************************************************************************
  129. Misc Functions
  130. ****************************************************************************}
  131. procedure Beep;
  132. begin
  133. end;
  134. {****************************************************************************
  135. Locale Functions
  136. ****************************************************************************}
  137. Procedure GetLocalTime(var SystemTime: TSystemTime);
  138. begin
  139. end ;
  140. Procedure InitAnsi;
  141. Var
  142. i : longint;
  143. begin
  144. { Fill table entries 0 to 127 }
  145. for i := 0 to 96 do
  146. UpperCaseTable[i] := chr(i);
  147. for i := 97 to 122 do
  148. UpperCaseTable[i] := chr(i - 32);
  149. for i := 123 to 191 do
  150. UpperCaseTable[i] := chr(i);
  151. Move (CPISO88591UCT,UpperCaseTable[192],SizeOf(CPISO88591UCT));
  152. for i := 0 to 64 do
  153. LowerCaseTable[i] := chr(i);
  154. for i := 65 to 90 do
  155. LowerCaseTable[i] := chr(i + 32);
  156. for i := 91 to 191 do
  157. LowerCaseTable[i] := chr(i);
  158. Move (CPISO88591LCT,UpperCaseTable[192],SizeOf(CPISO88591UCT));
  159. end;
  160. Procedure InitInternational;
  161. begin
  162. InitInternationalGeneric;
  163. InitAnsi;
  164. end;
  165. function SysErrorMessage(ErrorCode: Integer): String;
  166. begin
  167. Str(Errorcode,Result);
  168. Result:='Error '+Result;
  169. end;
  170. {****************************************************************************
  171. OS utility functions
  172. ****************************************************************************}
  173. Function GetEnvironmentVariable(Const EnvVar : String) : String;
  174. begin
  175. Result:=StrPas(beos.Getenv(PChar(EnvVar)));
  176. end;
  177. Function GetEnvironmentVariableCount : Integer;
  178. begin
  179. // Result:=FPCCountEnvVar(EnvP);
  180. Result:=0;
  181. end;
  182. Function GetEnvironmentString(Index : Integer) : String;
  183. begin
  184. // Result:=FPCGetEnvStrFromP(Envp,Index);
  185. Result:='';
  186. end;
  187. function ExecuteProcess (const Path: AnsiString; const ComLine: AnsiString):
  188. integer;
  189. var
  190. CommandLine: AnsiString;
  191. begin
  192. { always surround the name of the application by quotes
  193. so that long filenames will always be accepted. But don't
  194. do it if there are already double quotes!
  195. }
  196. if pos('"',path)=0 then
  197. CommandLine:='"'+path+'"'
  198. else
  199. CommandLine:=path;
  200. if ComLine <> '' then
  201. CommandLine := Commandline + ' ' + ComLine;
  202. ExecuteProcess := beos.shell (CommandLine);
  203. end;
  204. function ExecuteProcess (const Path: AnsiString;
  205. const ComLine: array of AnsiString): integer;
  206. {$WARNING Should be probably changed according to the Unix version}
  207. var
  208. CommandLine: AnsiString;
  209. I: integer;
  210. begin
  211. Commandline := '';
  212. for I := 0 to High (ComLine) do
  213. if Pos (' ', ComLine [I]) <> 0 then
  214. CommandLine := CommandLine + ' ' + '"' + ComLine [I] + '"'
  215. else
  216. CommandLine := CommandLine + ' ' + Comline [I];
  217. ExecuteProcess := ExecuteProcess (Path, CommandLine);
  218. end;
  219. {****************************************************************************
  220. Initialization code
  221. ****************************************************************************}
  222. Initialization
  223. InitExceptions; { Initialize exceptions. OS independent }
  224. InitInternational; { Initialize internationalization settings }
  225. Finalization
  226. DoneExceptions;
  227. end.