sysutils.pp 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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. { used OS file system APIs use ansistring }
  28. {$define SYSUTILS_HAS_ANSISTR_FILEUTIL_IMPL}
  29. { Include platform independent implementation part }
  30. {$i sysutils.inc}
  31. {****************************************************************************
  32. File Functions
  33. ****************************************************************************}
  34. function FileOpen(const FileName: rawbytestring; Mode: Integer): LongInt;
  35. var
  36. NDSFlags: longint;
  37. SystemFileName: RawByteString;
  38. begin
  39. SystemFileName:=ToSingleByteFileSystemEncodedFileName(FileName);
  40. NDSFlags := 0;
  41. case (Mode and (fmOpenRead or fmOpenWrite or fmOpenReadWrite)) of
  42. fmOpenRead : NDSFlags := NDSFlags or O_RdOnly;
  43. fmOpenWrite : NDSFlags := NDSFlags or O_WrOnly;
  44. fmOpenReadWrite : NDSFlags := NDSFlags or O_RdWr;
  45. end;
  46. FileOpen := _open(pchar(SystemFileName), NDSFlags);
  47. end;
  48. function FileGetDate(Handle: LongInt) : LongInt;
  49. begin
  50. result := -1;
  51. end;
  52. function FileSetDate(Handle, Age: LongInt) : LongInt;
  53. begin
  54. result := -1;
  55. end;
  56. function FileCreate(const FileName: RawByteString) : LongInt;
  57. var
  58. SystemFileName: RawByteString;
  59. begin
  60. SystemFileName:=ToSingleByteFileSystemEncodedFileName(FileName);
  61. FileCreate:=_open(pointer(SystemFileName), O_RdWr or O_Creat or O_Trunc);
  62. end;
  63. function FileCreate(const FileName: RawByteString; Rights: integer): LongInt;
  64. var
  65. SystemFileName: RawByteString;
  66. begin
  67. SystemFileName:=ToSingleByteFileSystemEncodedFileName(FileName);
  68. FileCreate:=_Open(pointer(SystemFileName),O_RdWr or O_Creat or O_Trunc,Rights);
  69. end;
  70. function FileCreate(const FileName: RawByteString; ShareMode : Integer; Rights: integer): LongInt;
  71. begin
  72. result := FileCreate(FileName, Rights);
  73. end;
  74. function FileRead(Handle: LongInt; Out Buffer; Count: LongInt): LongInt;
  75. begin
  76. FileRead := _Read(Handle, Buffer, Count);
  77. end;
  78. function FileWrite(Handle: LongInt; const Buffer; Count: LongInt): LongInt;
  79. begin
  80. FileWrite := _Write(Handle, @Buffer, Count);
  81. end;
  82. function FileSeek(Handle, FOffset, Origin: LongInt) : LongInt;
  83. begin
  84. result := longint(FileSeek(Handle, int64(FOffset), Origin));
  85. end;
  86. function FileSeek(Handle: LongInt; FOffset: Int64; Origin: Longint): Int64;
  87. begin
  88. FileSeek := _lSeek(Handle, FOffset, Origin);
  89. end;
  90. procedure FileClose(Handle: LongInt);
  91. begin
  92. _close(Handle);
  93. end;
  94. function FileTruncate(Handle: THandle; Size: Int64): Boolean;
  95. begin
  96. if Size > high (longint) then
  97. FileTruncate := false
  98. else
  99. FileTruncate:=(_truncate(Handle,Size) = 0);
  100. end;
  101. function DeleteFile(const FileName: string) : Boolean;
  102. begin
  103. Result := _UnLink(pointer(FileName))>= 0;
  104. end;
  105. function RenameFile(const OldName, NewName: string): Boolean;
  106. begin
  107. RenameFile := _Rename(pointer(OldNAme), pointer(NewName)) >= 0;
  108. end;
  109. (****** end of non portable routines ******)
  110. Function FileAge (Const FileName : String): Longint;
  111. var
  112. info: Stat;
  113. begin
  114. if (_stat(pchar(FileName), Info) < 0) or S_ISDIR(info.st_mode) then
  115. exit(-1)
  116. else
  117. Result := (info.st_mtime);
  118. end;
  119. Function FileExists (Const FileName : String) : Boolean;
  120. begin
  121. FileExists := _Access(pointer(filename), F_OK) = 0;
  122. end;
  123. Function FindFirst (Const Path : String; Attr : Longint; Out Rslt : TSearchRec) : Longint;
  124. begin
  125. result := -1;
  126. end;
  127. Function FindNext (Var Rslt : TSearchRec) : Longint;
  128. begin
  129. result := -1;
  130. end;
  131. Procedure FindClose (Var F : TSearchrec);
  132. begin
  133. end;
  134. Function FileGetAttr (Const FileName : String) : Longint;
  135. Var Info : TStat;
  136. begin
  137. If _stat(pchar(FileName), Info) <> 0 then
  138. Result := -1
  139. Else
  140. Result := (Info.st_mode shr 16) and $ffff;
  141. end;
  142. Function FileSetAttr (Const Filename : String; Attr: longint) : Longint;
  143. begin
  144. result := -1;
  145. end;
  146. {****************************************************************************
  147. Disk Functions
  148. ****************************************************************************}
  149. Procedure AddDisk(const path:string);
  150. begin
  151. end;
  152. Function DiskFree(Drive: Byte): int64;
  153. Begin
  154. result := -1;
  155. End;
  156. Function DiskSize(Drive: Byte): int64;
  157. Begin
  158. result := -1;
  159. End;
  160. Function GetCurrentDir : String;
  161. begin
  162. result := '';
  163. end;
  164. Function SetCurrentDir (Const NewDir : String) : Boolean;
  165. begin
  166. result := false;
  167. end;
  168. Function CreateDir (Const NewDir : String) : Boolean;
  169. begin
  170. result := false;
  171. end;
  172. Function RemoveDir (Const Dir : String) : Boolean;
  173. begin
  174. result := false;
  175. end;
  176. function DirectoryExists(const Directory: string): Boolean;
  177. begin
  178. result := false;
  179. end;
  180. {****************************************************************************
  181. Misc Functions
  182. ****************************************************************************}
  183. Procedure SysBeep;
  184. begin
  185. end;
  186. {****************************************************************************
  187. Locale Functions
  188. ****************************************************************************}
  189. Procedure GetLocalTime(var SystemTime: TSystemTime);
  190. begin
  191. end ;
  192. function SysErrorMessage(ErrorCode: Integer): String;
  193. begin
  194. { Result:=StrError(ErrorCode);}
  195. result := '';
  196. end;
  197. {****************************************************************************
  198. OS utility functions
  199. ****************************************************************************}
  200. Function GetEnvironmentVariable(Const EnvVar : String) : String;
  201. begin
  202. result := '';
  203. end;
  204. Function GetEnvironmentVariableCount : Integer;
  205. begin
  206. result := -1;
  207. end;
  208. Function GetEnvironmentString(Index : Integer) : String;
  209. begin
  210. result := '';
  211. end;
  212. function ExecuteProcess (const Path: AnsiString; const ComLine: AnsiString;Flags:TExecuteFlags=[]): integer;
  213. begin
  214. result := -1;
  215. end;
  216. function ExecuteProcess (const Path: AnsiString;
  217. const ComLine: array of AnsiString;Flags:TExecuteFlags=[]): integer;
  218. begin
  219. result := -1;
  220. end;
  221. {****************************************************************************
  222. Initialization code
  223. ****************************************************************************}
  224. Initialization
  225. InitExceptions;
  226. Finalization
  227. DoneExceptions;
  228. end.