sysutils.pp 6.5 KB

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