sysutils.pp 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2004 by Karoly Balogh
  4. Sysutils unit for Nintendo DS.
  5. This unit is based on the MorphOS one and is adapted for Nintendo DS
  6. simply by stripping out all stuff inside funcs and procs.
  7. Copyright (c) 2006 by Francesco Lombardi
  8. Based on Amiga version by Carl Eric Codere, and other
  9. parts of the RTL
  10. See the file COPYING.FPC, included in this distribution,
  11. for details about the copyright.
  12. This program is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  15. **********************************************************************}
  16. unit sysutils;
  17. interface
  18. {$MODE objfpc}
  19. {$MODESWITCH OUT}
  20. { force ansistrings }
  21. {$H+}
  22. { Include platform independent interface part }
  23. {$i sysutilh.inc}
  24. implementation
  25. uses
  26. sysconst;
  27. { Include platform independent implementation part }
  28. {$i sysutils.inc}
  29. {****************************************************************************
  30. File Functions
  31. ****************************************************************************}
  32. function FileOpen(const FileName: string; Mode: Integer): LongInt;
  33. var
  34. NDSFlags: longint;
  35. begin
  36. NDSFlags := 0;
  37. case (Mode and (fmOpenRead or fmOpenWrite or fmOpenReadWrite)) of
  38. fmOpenRead : NDSFlags := NDSFlags or O_RdOnly;
  39. fmOpenWrite : NDSFlags := NDSFlags or O_WrOnly;
  40. fmOpenReadWrite : NDSFlags := NDSFlags or O_RdWr;
  41. end;
  42. FileOpen := _open(pchar(FileName), NDSFlags);
  43. end;
  44. function FileGetDate(Handle: LongInt) : LongInt;
  45. begin
  46. result := -1;
  47. end;
  48. function FileSetDate(Handle, Age: LongInt) : LongInt;
  49. begin
  50. result := -1;
  51. end;
  52. function FileCreate(const FileName: string) : LongInt;
  53. begin
  54. FileCreate:=_open(pointer(FileName), O_RdWr or O_Creat or O_Trunc);
  55. end;
  56. function FileCreate(const FileName: string; Rights: integer): LongInt;
  57. begin
  58. FileCreate:=_Open(pointer(FileName),O_RdWr or O_Creat or O_Trunc,Rights);
  59. end;
  60. function FileCreate(const FileName: string; ShareMode : Integer; Rights: integer): LongInt;
  61. begin
  62. result := FileCreate(FileName, Rights);
  63. end;
  64. function FileRead(Handle: LongInt; Out Buffer; Count: LongInt): LongInt;
  65. begin
  66. FileRead := _Read(Handle, Buffer, Count);
  67. end;
  68. function FileWrite(Handle: LongInt; const Buffer; Count: LongInt): LongInt;
  69. begin
  70. FileWrite := _Write(Handle, @Buffer, Count);
  71. end;
  72. function FileSeek(Handle, FOffset, Origin: LongInt) : LongInt;
  73. begin
  74. result := longint(FileSeek(Handle, int64(FOffset), Origin));
  75. end;
  76. function FileSeek(Handle: LongInt; FOffset: Int64; Origin: Longint): Int64;
  77. begin
  78. FileSeek := _lSeek(Handle, FOffset, Origin);
  79. end;
  80. procedure FileClose(Handle: LongInt);
  81. begin
  82. _close(Handle);
  83. end;
  84. function FileTruncate(Handle: THandle; Size: Int64): Boolean;
  85. begin
  86. if Size > high (longint) then
  87. FileTruncate := false
  88. else
  89. FileTruncate:=(_truncate(Handle,Size) = 0);
  90. end;
  91. function DeleteFile(const FileName: string) : Boolean;
  92. begin
  93. Result := _UnLink(pointer(FileName))>= 0;
  94. end;
  95. function RenameFile(const OldName, NewName: string): Boolean;
  96. begin
  97. RenameFile := _Rename(pointer(OldNAme), pointer(NewName)) >= 0;
  98. end;
  99. (****** end of non portable routines ******)
  100. Function FileAge (Const FileName : String): Longint;
  101. var
  102. info: Stat;
  103. begin
  104. if (_stat(pchar(FileName), Info) < 0) or S_ISDIR(info.st_mode) then
  105. exit(-1)
  106. else
  107. Result := (info.st_mtime);
  108. end;
  109. Function FileExists (Const FileName : String) : Boolean;
  110. begin
  111. FileExists := _Access(pointer(filename), F_OK) = 0;
  112. end;
  113. Function FindFirst (Const Path : String; Attr : Longint; Out Rslt : TSearchRec) : Longint;
  114. begin
  115. result := -1;
  116. end;
  117. Function FindNext (Var Rslt : TSearchRec) : Longint;
  118. begin
  119. result := -1;
  120. end;
  121. Procedure FindClose (Var F : TSearchrec);
  122. begin
  123. end;
  124. Function FileGetAttr (Const FileName : String) : Longint;
  125. Var Info : TStat;
  126. begin
  127. If _stat(pchar(FileName), Info) <> 0 then
  128. Result := -1
  129. Else
  130. Result := (Info.st_mode shr 16) and $ffff;
  131. end;
  132. Function FileSetAttr (Const Filename : String; Attr: longint) : Longint;
  133. begin
  134. result := -1;
  135. end;
  136. {****************************************************************************
  137. Disk Functions
  138. ****************************************************************************}
  139. Procedure AddDisk(const path:string);
  140. begin
  141. end;
  142. Function DiskFree(Drive: Byte): int64;
  143. Begin
  144. result := -1;
  145. End;
  146. Function DiskSize(Drive: Byte): int64;
  147. Begin
  148. result := -1;
  149. End;
  150. Function GetCurrentDir : String;
  151. begin
  152. result := '';
  153. end;
  154. Function SetCurrentDir (Const NewDir : String) : Boolean;
  155. begin
  156. result := false;
  157. end;
  158. Function CreateDir (Const NewDir : String) : Boolean;
  159. begin
  160. result := false;
  161. end;
  162. Function RemoveDir (Const Dir : String) : Boolean;
  163. begin
  164. result := false;
  165. end;
  166. function DirectoryExists(const Directory: string): Boolean;
  167. begin
  168. result := false;
  169. end;
  170. {****************************************************************************
  171. Misc Functions
  172. ****************************************************************************}
  173. Procedure SysBeep;
  174. begin
  175. end;
  176. {****************************************************************************
  177. Locale Functions
  178. ****************************************************************************}
  179. Procedure GetLocalTime(var SystemTime: TSystemTime);
  180. begin
  181. end ;
  182. function SysErrorMessage(ErrorCode: Integer): String;
  183. begin
  184. { Result:=StrError(ErrorCode);}
  185. result := '';
  186. end;
  187. {****************************************************************************
  188. OS utility functions
  189. ****************************************************************************}
  190. Function GetEnvironmentVariable(Const EnvVar : String) : String;
  191. begin
  192. result := '';
  193. end;
  194. Function GetEnvironmentVariableCount : Integer;
  195. begin
  196. result := -1;
  197. end;
  198. Function GetEnvironmentString(Index : Integer) : String;
  199. begin
  200. result := '';
  201. end;
  202. function ExecuteProcess (const Path: AnsiString; const ComLine: AnsiString;Flags:TExecuteFlags=[]): integer;
  203. begin
  204. result := -1;
  205. end;
  206. function ExecuteProcess (const Path: AnsiString;
  207. const ComLine: array of AnsiString;Flags:TExecuteFlags=[]): integer;
  208. begin
  209. result := -1;
  210. end;
  211. {****************************************************************************
  212. Initialization code
  213. ****************************************************************************}
  214. Initialization
  215. InitExceptions;
  216. Finalization
  217. DoneExceptions;
  218. end.