sysutils.pp 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2016 by Free Pascal development team
  4. Sysutils unit for Atari
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. unit sysutils;
  12. interface
  13. {$MODE objfpc}
  14. {$MODESWITCH OUT}
  15. { force ansistrings }
  16. {$H+}
  17. {$modeswitch typehelpers}
  18. {$modeswitch advancedrecords}
  19. {$DEFINE OS_FILESETDATEBYNAME}
  20. {$DEFINE HAS_SLEEP}
  21. {$DEFINE HAS_OSERROR}
  22. {OS has only 1 byte version for ExecuteProcess}
  23. {$define executeprocuni}
  24. { used OS file system APIs use ansistring }
  25. {$define SYSUTILS_HAS_ANSISTR_FILEUTIL_IMPL}
  26. { OS has an ansistring/single byte environment variable API }
  27. {$define SYSUTILS_HAS_ANSISTR_ENVVAR_IMPL}
  28. { Include platform independent interface part }
  29. {$i sysutilh.inc}
  30. { Platform dependent calls }
  31. implementation
  32. uses
  33. { dos,} sysconst;
  34. {$DEFINE FPC_FEXPAND_UNC} (* UNC paths are supported *)
  35. {$DEFINE FPC_FEXPAND_DRIVES} (* Full paths begin with drive specification *)
  36. { Include platform independent implementation part }
  37. {$i sysutils.inc}
  38. {****************************************************************************
  39. File Functions
  40. ****************************************************************************}
  41. {$I-}{ Required for correct usage of these routines }
  42. (****** non portable routines ******)
  43. function FileOpen(const FileName: rawbytestring; Mode: Integer): THandle;
  44. begin
  45. end;
  46. function FileGetDate(Handle: THandle) : LongInt;
  47. begin
  48. result:=-1;
  49. end;
  50. function FileSetDate(Handle: THandle; Age: LongInt) : LongInt;
  51. begin
  52. result:=0;
  53. end;
  54. function FileSetDate(const FileName: RawByteString; Age: LongInt) : LongInt;
  55. begin
  56. result:=-1;
  57. end;
  58. function FileCreate(const FileName: RawByteString) : THandle;
  59. begin
  60. result:=-1;
  61. end;
  62. function FileCreate(const FileName: RawByteString; Rights: integer): THandle;
  63. begin
  64. {$WARNING FIX ME! To do: FileCreate Access Modes}
  65. FileCreate:=FileCreate(FileName);
  66. end;
  67. function FileCreate(const FileName: RawByteString; ShareMode: integer; Rights : integer): THandle;
  68. begin
  69. {$WARNING FIX ME! To do: FileCreate Access Modes}
  70. FileCreate:=FileCreate(FileName);
  71. end;
  72. function FileRead(Handle: THandle; out Buffer; Count: LongInt): LongInt;
  73. begin
  74. FileRead:=-1;
  75. if (Count<=0) or (Handle=0) or (Handle=-1) then exit;
  76. end;
  77. function FileWrite(Handle: THandle; const Buffer; Count: LongInt): LongInt;
  78. begin
  79. FileWrite:=-1;
  80. if (Count<=0) or (Handle=0) or (Handle=-1) then exit;
  81. end;
  82. function FileSeek(Handle: THandle; FOffset, Origin: LongInt) : LongInt;
  83. begin
  84. FileSeek:=-1;
  85. end;
  86. function FileSeek(Handle: THandle; FOffset: Int64; Origin: Longint): Int64;
  87. begin
  88. FileSeek:=FileSeek(Handle,LongInt(FOffset),LongInt(Origin));
  89. end;
  90. procedure FileClose(Handle: THandle);
  91. begin
  92. if (Handle=0) or (Handle=-1) then exit;
  93. end;
  94. function FileTruncate(Handle: THandle; Size: Int64): Boolean;
  95. begin
  96. FileTruncate:=False;
  97. end;
  98. function DeleteFile(const FileName: RawByteString) : Boolean;
  99. begin
  100. end;
  101. function RenameFile(const OldName, NewName: RawByteString): Boolean;
  102. begin
  103. end;
  104. (****** end of non portable routines ******)
  105. function FileAge (const FileName : RawByteString): Longint;
  106. begin
  107. result:=-1;
  108. end;
  109. function FileExists (const FileName : RawByteString) : Boolean;
  110. begin
  111. result:=false;
  112. end;
  113. Function InternalFindFirst (Const Path : RawByteString; Attr : Longint; out Rslt : TAbstractSearchRec; var Name: RawByteString) : Longint;
  114. begin
  115. result:=-1; { We emulate Linux/Unix behaviour, and return -1 on errors. }
  116. end;
  117. Function InternalFindNext (var Rslt : TAbstractSearchRec; var Name : RawByteString) : Longint;
  118. begin
  119. result:=-1;
  120. end;
  121. Procedure InternalFindClose(var Handle: THandle);
  122. begin
  123. end;
  124. (****** end of non portable routines ******)
  125. Function FileGetAttr (Const FileName : RawByteString) : Longint;
  126. begin
  127. FileGetAttr := -1
  128. end;
  129. Function FileSetAttr (Const Filename : RawByteString; Attr: longint) : Longint;
  130. begin
  131. FileSetAttr := -1;
  132. end;
  133. {****************************************************************************
  134. Disk Functions
  135. ****************************************************************************}
  136. // New easier DiskSize()
  137. //
  138. function DiskSize(Drive: AnsiString): Int64;
  139. begin
  140. DiskSize := -1;
  141. end;
  142. function DiskSize(Drive: Byte): Int64;
  143. begin
  144. DiskSize := -1;
  145. end;
  146. // New easier DiskFree()
  147. //
  148. function DiskFree(Drive: AnsiString): Int64;
  149. begin
  150. DiskFree := -1;
  151. end;
  152. function DiskFree(Drive: Byte): Int64;
  153. begin
  154. DiskFree := -1;
  155. end;
  156. function DirectoryExists(const Directory: RawByteString): Boolean;
  157. begin
  158. result:=false;
  159. end;
  160. {****************************************************************************
  161. Locale Functions
  162. ****************************************************************************}
  163. Procedure GetLocalTime(var SystemTime: TSystemTime);
  164. begin
  165. end;
  166. Procedure InitAnsi;
  167. Var
  168. i : longint;
  169. begin
  170. { Fill table entries 0 to 127 }
  171. for i := 0 to 96 do
  172. UpperCaseTable[i] := chr(i);
  173. for i := 97 to 122 do
  174. UpperCaseTable[i] := chr(i - 32);
  175. for i := 123 to 191 do
  176. UpperCaseTable[i] := chr(i);
  177. Move (CPISO88591UCT,UpperCaseTable[192],SizeOf(CPISO88591UCT));
  178. for i := 0 to 64 do
  179. LowerCaseTable[i] := chr(i);
  180. for i := 65 to 90 do
  181. LowerCaseTable[i] := chr(i + 32);
  182. for i := 91 to 191 do
  183. LowerCaseTable[i] := chr(i);
  184. Move (CPISO88591LCT,UpperCaseTable[192],SizeOf(CPISO88591UCT));
  185. end;
  186. Procedure InitInternational;
  187. begin
  188. InitInternationalGeneric;
  189. InitAnsi;
  190. end;
  191. function SysErrorMessage(ErrorCode: Integer): String;
  192. begin
  193. Result:=Format(SUnknownErrorCode,[ErrorCode]);
  194. end;
  195. function GetLastOSError: Integer;
  196. begin
  197. result:=-1;
  198. end;
  199. {****************************************************************************
  200. OS utility functions
  201. ****************************************************************************}
  202. function GetPathString: String;
  203. begin
  204. result := '';
  205. end;
  206. Function GetEnvironmentVariable(Const EnvVar : String) : String;
  207. begin
  208. end;
  209. Function GetEnvironmentVariableCount : Integer;
  210. begin
  211. end;
  212. Function GetEnvironmentString(Index : Integer) : {$ifdef FPC_RTL_UNICODE}UnicodeString{$else}AnsiString{$endif};
  213. begin
  214. end;
  215. function ExecuteProcess (const Path: RawByteString; const ComLine: RawByteString;Flags:TExecuteFlags=[]):
  216. integer;
  217. begin
  218. end;
  219. function ExecuteProcess (const Path: RawByteString;
  220. const ComLine: array of RawByteString;Flags:TExecuteFlags=[]): integer;
  221. var
  222. CommandLine: RawByteString;
  223. I: integer;
  224. begin
  225. Commandline := '';
  226. for I := 0 to High (ComLine) do
  227. if Pos (' ', ComLine [I]) <> 0 then
  228. CommandLine := CommandLine + ' ' + '"' + ToSingleByteFileSystemEncodedFileName(ComLine [I]) + '"'
  229. else
  230. CommandLine := CommandLine + ' ' + ToSingleByteFileSystemEncodedFileName(Comline [I]);
  231. ExecuteProcess := ExecuteProcess (Path, CommandLine);
  232. end;
  233. procedure Sleep(Milliseconds: cardinal);
  234. begin
  235. end;
  236. {****************************************************************************
  237. Initialization code
  238. ****************************************************************************}
  239. Initialization
  240. InitExceptions;
  241. InitInternational; { Initialize internationalization settings }
  242. OnBeep:=Nil; { No SysBeep() on Atari for now. }
  243. Finalization
  244. DoneExceptions;
  245. end.