sysutils.pp 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2021 by the Free Pascal development team.
  4. Sysutils unit for The WebAssembly System Interface (WASI).
  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. {$inline on}
  12. unit sysutils;
  13. interface
  14. {$MODE objfpc}
  15. {$MODESWITCH out}
  16. { force ansistrings }
  17. {$H+}
  18. {$modeswitch typehelpers}
  19. {$modeswitch advancedrecords}
  20. uses
  21. wasiapi;
  22. {$DEFINE HAS_SLEEP}
  23. {$DEFINE HAS_GETTICKCOUNT64}
  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. implementation
  31. uses
  32. sysconst;
  33. {$DEFINE FPC_FEXPAND_UNC} (* UNC paths are supported *)
  34. {$DEFINE FPC_FEXPAND_DRIVES} (* Full paths begin with drive specification *)
  35. {$DEFINE HAS_LOCALTIMEZONEOFFSET}
  36. {$DEFINE executeprocuni} (* Only 1 byte version of ExecuteProcess is provided by the OS *)
  37. { Include platform independent implementation part }
  38. {$i sysutils.inc}
  39. function GetTickCount64: QWord;
  40. var
  41. NanoSecsPast: __wasi_timestamp_t;
  42. begin
  43. if __wasi_clock_time_get(__WASI_CLOCKID_MONOTONIC,1000000,@NanoSecsPast)=__WASI_ERRNO_SUCCESS then
  44. Result:=NanoSecsPast div 1000000
  45. else
  46. Result:=0;
  47. end;
  48. {****************************************************************************
  49. File Functions
  50. ****************************************************************************}
  51. Function FileOpen (Const FileName : RawByteString; Mode : Integer) : THandle;
  52. Begin
  53. end;
  54. Function FileCreate (Const FileName : RawByteString) : THandle;
  55. begin
  56. end;
  57. Function FileCreate (Const FileName : RawByteString; ShareMode:integer; Rights : integer) : THandle;
  58. begin
  59. end;
  60. Function FileCreate (Const FileName : RawByteString; Rights:integer) : THandle;
  61. begin
  62. end;
  63. Function FileRead (Handle : THandle; Out Buffer; Count : longint) : Longint;
  64. begin
  65. end;
  66. Function FileWrite (Handle : THandle; const Buffer; Count : Longint) : Longint;
  67. begin
  68. end;
  69. Function FileSeek (Handle : THandle; FOffset, Origin : Longint) : Longint;
  70. begin
  71. end;
  72. Function FileSeek (Handle : THandle; FOffset: Int64; Origin: {Integer}Longint) : Int64;
  73. begin
  74. end;
  75. Procedure FileClose (Handle : THandle);
  76. begin
  77. end;
  78. Function FileTruncate (Handle: THandle; Size: Int64) : boolean;
  79. begin
  80. end;
  81. Function FileAge (Const FileName : RawByteString): Int64;
  82. begin
  83. end;
  84. function FileGetSymLinkTarget(const FileName: RawByteString; out SymLinkRec: TRawbyteSymLinkRec): Boolean;
  85. begin
  86. Result := False;
  87. end;
  88. function FileExists (const FileName: RawByteString; FollowLink : Boolean): boolean;
  89. begin
  90. end;
  91. Function DirectoryExists (Const Directory : RawByteString; FollowLink : Boolean) : Boolean;
  92. begin
  93. end;
  94. Function InternalFindFirst (Const Path : RawByteString; Attr : Longint; out Rslt : TAbstractSearchRec; var Name: RawByteString) : Longint;
  95. begin
  96. { not yet implemented }
  97. Result := -1;
  98. end;
  99. Function InternalFindNext (var Rslt : TAbstractSearchRec; var Name : RawByteString) : Longint;
  100. begin
  101. { not yet implemented }
  102. Result := -1;
  103. end;
  104. Procedure InternalFindClose(var Handle: THandle);
  105. begin
  106. end;
  107. Function FileGetDate (Handle : THandle) : Int64;
  108. begin
  109. end;
  110. Function FileSetDate (Handle : THandle; Age : Int64) : Longint;
  111. begin
  112. end;
  113. Function FileGetAttr (Const FileName : RawByteString) : Longint;
  114. begin
  115. end;
  116. Function FileSetAttr (Const Filename : RawByteString; Attr: longint) : Longint;
  117. begin
  118. end;
  119. Function DeleteFile (Const FileName : RawByteString) : Boolean;
  120. begin
  121. end;
  122. Function RenameFile (Const OldName, NewName : RawByteString) : Boolean;
  123. begin
  124. end;
  125. {****************************************************************************
  126. Disk Functions
  127. ****************************************************************************}
  128. function diskfree(drive : byte) : int64;
  129. begin
  130. end;
  131. function disksize(drive : byte) : int64;
  132. begin
  133. end;
  134. {****************************************************************************
  135. Time Functions
  136. ****************************************************************************}
  137. {$I tzenv.inc}
  138. Procedure GetLocalTime(var SystemTime: TSystemTime);
  139. begin
  140. end ;
  141. {****************************************************************************
  142. Misc Functions
  143. ****************************************************************************}
  144. procedure sysBeep;
  145. begin
  146. end;
  147. {****************************************************************************
  148. Locale Functions
  149. ****************************************************************************}
  150. procedure InitAnsi;
  151. begin
  152. end;
  153. Procedure InitInternational;
  154. begin
  155. InitInternationalGeneric;
  156. InitAnsi;
  157. end;
  158. function SysErrorMessage(ErrorCode: Integer): String;
  159. begin
  160. Result:=Format(SUnknownErrorCode,[ErrorCode]);
  161. end;
  162. {****************************************************************************
  163. Os utils
  164. ****************************************************************************}
  165. Function GetEnvironmentVariable(Const EnvVar : String) : String;
  166. begin
  167. end;
  168. Function GetEnvironmentVariableCount : Integer;
  169. begin
  170. end;
  171. Function GetEnvironmentString(Index : Integer) : {$ifdef FPC_RTL_UNICODE}UnicodeString{$else}AnsiString{$endif};
  172. begin
  173. end;
  174. function ExecuteProcess(Const Path: RawByteString; Const ComLine: RawByteString;Flags:TExecuteFlags=[]):integer;
  175. begin
  176. end;
  177. function ExecuteProcess (const Path: RawByteString;
  178. const ComLine: array of RawByteString;Flags:TExecuteFlags=[]): integer;
  179. begin
  180. end;
  181. {*************************************************************************
  182. Sleep
  183. *************************************************************************}
  184. procedure Sleep (MilliSeconds: Cardinal);
  185. begin
  186. end;
  187. {****************************************************************************
  188. Initialization code
  189. ****************************************************************************}
  190. Initialization
  191. InitExceptions; { Initialize exceptions. OS independent }
  192. InitInternational; { Initialize internationalization settings }
  193. OnBeep:=@SysBeep;
  194. InitTZ;
  195. Finalization
  196. FreeTerminateProcs;
  197. DoneExceptions;
  198. end.