sysutils.pp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2004 by the Free Pascal development team.
  5. Sysutils unit for netware (libc)
  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 Libc,DOS;
  18. TYPE
  19. TNetwareLibcFindData =
  20. RECORD
  21. DirP : Pdirent; { used for opendir }
  22. EntryP: Pdirent; { and readdir }
  23. Magic : longint; { to avoid abends with uninitialized TSearchRec }
  24. _mask : string; { search mask i.e. *.* }
  25. _dir : string; { directory where to search }
  26. _attr : longint; { specified attribute }
  27. fname : string; { full pathname of found file }
  28. END;
  29. { Include platform independent interface part }
  30. {$i sysutilh.inc}
  31. { additional NetWare file flags}
  32. CONST
  33. faSHARE = M_A_SHARE shr 16; // Sharable file
  34. //faNO_SUBALLOC = $00000800; // Don't sub alloc. this file
  35. faTRANS = M_A_TRANS shr 16; // Transactional file (TTS usable)
  36. //faREADAUD = $00004000; // clib only: Read audit
  37. //faWRITAUD = $00008000; // clib only: Write audit
  38. faIMMPURG = M_A_IMMPURG shr 16; // Immediate purge
  39. faNORENAM = M_A_NORENAM shr 16; // Rename inhibit
  40. faNODELET = M_A_NODELET shr 16; // Delete inhibit
  41. faNOCOPY = M_A_NOCOPY shr 16; // Copy inhibit
  42. //faFILE_MIGRATED = $00400000; // clib only: File has been migrated
  43. //faDONT_MIGRATE = $00800000; // clib only: Don't migrate this file
  44. faIMMEDIATE_COMPRESS = M_A_IMMCOMPRESS shr 16; // Compress this file immediately
  45. faFILE_COMPRESSED = M_A_FILE_COMPRESSED shr 16; // File is compressed
  46. faDONT_COMPRESS = M_A_DONT_COMPRESS shr 16; // Don't compress this file
  47. faCANT_COMPRESS = M_A_CANT_COMPRESS shr 16; // Can't compress this file
  48. //faATTR_ARCHIVE = $40000000; // clib only: Entry has had an EA modified,
  49. // an ownerID changed, or trustee
  50. // info changed, etc.
  51. faSetNetwareAttrs = M_A_BITS_SIGNIFICANT; // if this is set, netware flags are changed also
  52. implementation
  53. uses
  54. sysconst;
  55. { Include platform independent implementation part }
  56. {$i sysutils.inc}
  57. {****************************************************************************
  58. File Functions
  59. ****************************************************************************}
  60. Function FileOpen (Const FileName : string; Mode : Integer) : Longint;
  61. VAR NWOpenFlags : longint;
  62. BEGIN
  63. NWOpenFlags:=0;
  64. Case (Mode and 3) of
  65. 0 : NWOpenFlags:=NWOpenFlags or O_RDONLY;
  66. 1 : NWOpenFlags:=NWOpenFlags or O_WRONLY;
  67. 2 : NWOpenFlags:=NWOpenFlags or O_RDWR;
  68. end;
  69. FileOpen := Fpopen (pchar(FileName),NWOpenFlags);
  70. //!! We need to set locking based on Mode !!
  71. end;
  72. Function FileCreate (Const FileName : String) : Longint;
  73. begin
  74. FileCreate:=Fpopen(Pchar(FileName),O_RdWr or O_Creat or O_Trunc or O_Binary);
  75. if FileCreate >= 0 then
  76. FileSetAttr (Filename, 0); // dont know why but open always sets ReadOnly flag
  77. end;
  78. Function FileCreate (Const FileName : String; mode:longint) : Longint;
  79. begin
  80. FileCreate:=FileCreate (FileName);
  81. end;
  82. Function FileRead (Handle : Longint; Var Buffer; Count : longint) : Longint;
  83. begin
  84. FileRead:=libc.fpread (Handle,@Buffer,Count);
  85. end;
  86. Function FileWrite (Handle : Longint; const Buffer; Count : Longint) : Longint;
  87. begin
  88. FileWrite:=libc.fpwrite (Handle,@Buffer,Count);
  89. end;
  90. Function FileSeek (Handle,FOffset,Origin : Longint) : Longint;
  91. begin
  92. FileSeek:=libc.fplseek (Handle,FOffset,Origin);
  93. end;
  94. Function FileSeek (Handle : Longint; FOffset,Origin : Int64) : Int64;
  95. begin
  96. FileSeek:=libc.fplseek64 (Handle,FOffset,Origin);
  97. end;
  98. Procedure FileClose (Handle : Longint);
  99. begin
  100. libc.fpclose(Handle);
  101. end;
  102. Function FileTruncate (Handle,Size: Longint) : boolean;
  103. begin
  104. FileTruncate:=(libc.fpchsize(Handle,Size) = 0);
  105. end;
  106. Function FileLock (Handle,FOffset,FLen : Longint) : Longint;
  107. begin
  108. {$warning FileLock not implemented}
  109. //FileLock := _lock (Handle,FOffset,FLen);
  110. end;
  111. Function FileLock (Handle : Longint; FOffset,FLen : Int64) : Longint;
  112. begin
  113. {$warning need to add 64bit FileLock call }
  114. //FileLock := FileLock (Handle, longint(FOffset),longint(FLen));
  115. end;
  116. Function FileUnlock (Handle,FOffset,FLen : Longint) : Longint;
  117. begin
  118. //FileUnlock := _unlock (Handle,FOffset,FLen);
  119. {$warning FileUnLock not implemented}
  120. end;
  121. Function FileUnlock (Handle : Longint; FOffset,FLen : Int64) : Longint;
  122. begin
  123. {$warning need to add 64bit FileUnlock call }
  124. //FileUnlock := FileUnlock (Handle, longint(FOffset),longint(FLen));
  125. end;
  126. Function FileAge (Const FileName : String): Longint;
  127. var Info : TStat;
  128. TM : TTM;
  129. begin
  130. If stat (pchar(FileName),Info) <> 0 then
  131. exit(-1)
  132. else
  133. begin
  134. localtime_r (Info.st_mtim.tv_sec,tm);
  135. with TM do
  136. result:=DateTimeToFileDate(EncodeDate(tm_year+1900,tm_mon+1,tm_mday)+EncodeTime(tm_hour,tm_min,tm_sec,0));
  137. end;
  138. end;
  139. Function FileExists (Const FileName : String) : Boolean;
  140. VAR Info : TStat;
  141. begin
  142. FileExists:=(stat(pchar(filename),Info) = 0);
  143. end;
  144. (*
  145. PROCEDURE find_setfields (VAR f : TsearchRec);
  146. VAR T : Dos.DateTime;
  147. BEGIN
  148. WITH F DO
  149. BEGIN
  150. IF FindData.Magic = $AD01 THEN
  151. BEGIN
  152. {attr := FindData.EntryP^.d_attr AND $FF;} // lowest 8 bit -> same as dos
  153. attr := FindData.EntryP^.d_flags; { return complete netware attributes }
  154. //!!UnpackTime(FindData.EntryP^.d_time + (LONGINT (FindData.EntryP^.d_date) SHL 16), T);
  155. //!!time := DateTimeToFileDate(EncodeDate(T.Year,T.Month,T.day)+EncodeTime(T.Hour,T.Min,T.Sec,0));
  156. size := FindData.EntryP^.d_size;
  157. name := strpas (FindData.EntryP^.d_name);
  158. END ELSE
  159. BEGIN
  160. FillChar (f,SIZEOF(f),0);
  161. END;
  162. END;
  163. END;*)
  164. Function UnixToWinAge(UnixAge : time_t): Longint;
  165. Var tm : TTm;
  166. begin
  167. libc.localtime_r (UnixAge, tm);
  168. with tm do
  169. Result:=DateTimeToFileDate(EncodeDate(tm_year+1900,tm_mon+1,tm_mday)+EncodeTime(tm_hour,tm_min,tm_sec,0));
  170. end;
  171. {returns true if attributes match}
  172. function find_setfields (var f : TsearchRec; var AttrsOk : boolean) : longint;
  173. var
  174. StatBuf : TStat;
  175. fname : string;
  176. begin
  177. result := 0;
  178. with F do
  179. begin
  180. if FindData.Magic = $AD02 then
  181. begin
  182. attr := (Pdirent(FindData.EntryP)^.d_mode shr 16) and $ffff;
  183. size := Pdirent(FindData.EntryP)^.d_size;
  184. name := strpas (Pdirent(FindData.EntryP)^.d_name);
  185. fname := FindData._dir + name;
  186. if stat (pchar(fname),StatBuf) = 0 then
  187. time := UnixToWinAge (StatBuf.st_mtim.tv_sec)
  188. else
  189. time := 0;
  190. AttrsOk := false;
  191. if (f.FindData._attr and faHidden) = 0 then
  192. if attr and faHidden > 0 then exit;
  193. if (f.FindData._attr and faDirectory) = 0 then
  194. if attr and faDirectory > 0 then exit;
  195. if (f.FindData._attr and faSysFile) = 0 then
  196. if attr and faSysFile > 0 then exit;
  197. AttrsOk := true;
  198. end else
  199. begin
  200. FillChar (f,sizeof(f),0);
  201. result := 18;
  202. end;
  203. end;
  204. end;
  205. (*
  206. Function FindFirst (Const Path : String; Attr : Longint; Var Rslt : TSearchRec) : Longint;
  207. begin
  208. IF path = '' then
  209. exit (18);
  210. Rslt.FindData.DirP := opendir (pchar(Path));
  211. IF Rslt.FindData.DirP = NIL THEN
  212. exit (18);
  213. //!!IF attr <> faAnyFile THEN
  214. //!! _SetReaddirAttribute (Rslt.FindData.DirP, attr);
  215. Rslt.FindData.Magic := $AD01;
  216. Rslt.FindData.EntryP := readdir (Rslt.FindData.DirP);
  217. if Rslt.FindData.EntryP = nil then
  218. begin
  219. closedir (Rslt.FindData.DirP);
  220. Rslt.FindData.DirP := NIL;
  221. result := 18;
  222. end else
  223. begin
  224. find_setfields (Rslt);
  225. result := 0;
  226. end;
  227. end;
  228. Function FindNext (Var Rslt : TSearchRec) : Longint;
  229. begin
  230. if Rslt.FindData.Magic <> $AD01 then
  231. exit (18);
  232. Rslt.FindData.EntryP := readdir (Rslt.FindData.DirP);
  233. if Rslt.FindData.EntryP = nil then
  234. exit (18);
  235. find_setfields (Rslt);
  236. result := 0;
  237. end;
  238. Procedure FindClose (Var F : TSearchrec);
  239. begin
  240. if F.FindData.Magic = $AD01 then
  241. begin
  242. if F.FindData.DirP <> nil then
  243. closedir (F.FindData.DirP);
  244. F.FindData.Magic := 0;
  245. F.FindData.DirP := NIL;
  246. F.FindData.EntryP := NIL;
  247. end;
  248. end;*)
  249. function findfirst(const path : string;attr : longint;var Rslt : TsearchRec) : longint;
  250. var
  251. path0 : string;
  252. p : longint;
  253. begin
  254. IF path = '' then
  255. begin
  256. result := 18;
  257. exit;
  258. end;
  259. Rslt.FindData._attr := attr;
  260. p := length (path);
  261. while (p > 0) and (not (path[p] in ['\','/'])) do
  262. dec (p);
  263. if p > 0 then
  264. begin
  265. Rslt.FindData._mask := copy (path,p+1,255);
  266. Rslt.FindData._dir := copy (path,1,p);
  267. end else
  268. begin
  269. Rslt.FindData._mask := path;
  270. Rslt.FindData._dir := GetCurrentDir;
  271. if (Rslt.FindData._dir[length(Rslt.FindData._dir)] <> '/') and
  272. (Rslt.FindData._dir[length(Rslt.FindData._dir)] <> '\') then
  273. Rslt.FindData._dir := Rslt.FindData._dir + '/';
  274. end;
  275. if Rslt.FindData._mask = '*' then Rslt.FindData._mask := '';
  276. if Rslt.FindData._mask = '*.*' then Rslt.FindData._mask := '';
  277. //writeln (stderr,'mask: "',Rslt._mask,'" dir:"',path0,'"');
  278. Pdirent(Rslt.FindData.DirP) := opendir (pchar(Rslt.FindData._dir));
  279. if Rslt.FindData.DirP = nil then
  280. result := 18
  281. else begin
  282. Rslt.FindData.Magic := $AD02;
  283. result := findnext (Rslt);
  284. end;
  285. end;
  286. function findnext(var Rslt : TsearchRec) : longint;
  287. var attrsOk : boolean;
  288. begin
  289. if Rslt.FindData.Magic <> $AD02 then
  290. begin
  291. result := 18;
  292. exit;
  293. end;
  294. result:=0;
  295. repeat
  296. Pdirent(Rslt.FindData.EntryP) := readdir (Pdirent(Rslt.FindData.DirP));
  297. if Rslt.FindData.EntryP = nil then
  298. result := 18
  299. else
  300. result := find_setfields (Rslt,attrsOk);
  301. if (result = 0) and (attrsOk) then
  302. begin
  303. if Rslt.FindData._mask = #0 then exit;
  304. if fnmatch(@Rslt.FindData._mask[1],Pdirent(Rslt.FindData.EntryP)^.d_name,FNM_CASEFOLD) = 0 then
  305. exit;
  306. end;
  307. until result <> 0;
  308. end;
  309. Procedure FindClose(Var f: TSearchRec);
  310. begin
  311. if F.FindData.Magic <> $AD02 then exit;
  312. doserror:=0;
  313. closedir (Pdirent(f.FindData.DirP));
  314. FillChar (f,sizeof(f),0);
  315. end;
  316. Function FileGetDate (Handle : Longint) : Longint;
  317. Var Info : TStat;
  318. _PTM : PTM;
  319. begin
  320. If fstat(Handle,Info) <> 0 then
  321. Result:=-1
  322. else
  323. begin
  324. _PTM := localtime (Info.st_mtim.tv_sec);
  325. IF _PTM = NIL THEN
  326. exit(-1)
  327. else
  328. with _PTM^ do
  329. Result:=DateTimeToFileDate(EncodeDate(tm_year+1900,tm_mon+1,tm_mday)+EncodeTime(tm_hour,tm_min,tm_sec,0));
  330. end;
  331. end;
  332. Function FileSetDate (Handle,Age : Longint) : Longint;
  333. Begin
  334. {dont know how to do that, utime needs filename}
  335. result := -1;
  336. end;
  337. Function FileGetAttr (Const FileName : String) : Longint;
  338. Var Info : TStat;
  339. begin
  340. If stat (pchar(FileName),Info) <> 0 then
  341. Result:=-1
  342. Else
  343. Result := (Info.st_mode shr 16) and $ffff;
  344. end;
  345. Function FileSetAttr (Const Filename : String; Attr: longint) : Longint;
  346. var
  347. StatBuf : TStat;
  348. newMode : longint;
  349. begin
  350. if stat (pchar(Filename),StatBuf) = 0 then
  351. begin
  352. {what should i do here ?
  353. only support sysutils-standard attributes or also support the extensions defined
  354. only for netware libc ?
  355. For now i allow the complete attributes if the bit faSetNetwareAttrs is set. Otherwise
  356. only the standard attributes can be modified}
  357. if attr and faSetNetwareAttrs > 0 then
  358. begin
  359. newmode := ((attr shl 16) and $ffff0000) or M_A_BITS_SIGNIFICANT;
  360. end else
  361. begin
  362. attr := (attr and $2f) shl 16;
  363. newmode := StatBuf.st_mode and ($ffff0000-M_A_RDONLY-M_A_HIDDEN- M_A_SYSTEM-M_A_SUBDIR-M_A_ARCH);
  364. newmode := newmode or (attr shl 16) or M_A_BITS_SIGNIFICANT;
  365. end;
  366. if chmod (pchar(Filename),newMode) < 0 then
  367. result := ___errno^ else
  368. result := 0;
  369. end else
  370. result := ___errno^;
  371. end;
  372. Function DeleteFile (Const FileName : String) : Boolean;
  373. begin
  374. Result:= (libc.UnLink (pchar(FileName)) = 0);
  375. end;
  376. Function RenameFile (Const OldName, NewName : String) : Boolean;
  377. begin
  378. RenameFile:=(libc.rename(pchar(OldName),pchar(NewName)) = 0);
  379. end;
  380. {****************************************************************************
  381. Disk Functions
  382. ****************************************************************************}
  383. {
  384. The Diskfree and Disksize functions need a file on the specified drive, since this
  385. is required for the statfs system call.
  386. These filenames are set in drivestr[0..26], and have been preset to :
  387. 0 - '.' (default drive - hence current dir is ok.)
  388. 1 - '/fd0/.' (floppy drive 1 - should be adapted to local system )
  389. 2 - '/fd1/.' (floppy drive 2 - should be adapted to local system )
  390. 3 - '/' (C: equivalent of dos is the root partition)
  391. 4..26 (can be set by you're own applications)
  392. ! Use AddDisk() to Add new drives !
  393. They both return -1 when a failure occurs.
  394. }
  395. Const
  396. FixDriveStr : array[0..3] of pchar=(
  397. '.',
  398. 'a:.',
  399. 'b:.',
  400. 'sys:/'
  401. );
  402. var
  403. Drives : byte;
  404. DriveStr : array[4..26] of pchar;
  405. Procedure AddDisk(const path:string);
  406. begin
  407. if not (DriveStr[Drives]=nil) then
  408. FreeMem(DriveStr[Drives],StrLen(DriveStr[Drives])+1);
  409. GetMem(DriveStr[Drives],length(Path)+1);
  410. StrPCopy(DriveStr[Drives],path);
  411. inc(Drives);
  412. if Drives>26 then
  413. Drives:=4;
  414. end;
  415. Function DiskFree(Drive: Byte): int64;
  416. //var fs : Tstatfs;
  417. Begin
  418. { if ((Drive<4) and (not (fixdrivestr[Drive]=nil)) and fsstat(StrPas(fixdrivestr[drive]),fs)) or
  419. ((not (drivestr[Drive]=nil)) and fsstat(StrPas(drivestr[drive]),fs)) then
  420. Diskfree:=int64(fs.bavail)*int64(fs.bsize)
  421. else
  422. Diskfree:=-1;}
  423. DiskFree := -1;
  424. ConsolePrintf ('warning: fpc sysutils.diskfree not implemented'#13#10);
  425. {$warning DiskFree not implemented (does it make sense ?) }
  426. End;
  427. Function DiskSize(Drive: Byte): int64;
  428. //var fs : statfs;
  429. Begin
  430. { if ((Drive<4) and (not (fixdrivestr[Drive]=nil)) and fsstat(StrPas(fixdrivestr[drive]),fs)) or
  431. ((not (drivestr[Drive]=nil)) and fsstat(StrPas(drivestr[drive]),fs)) then
  432. DiskSize:=int64(fs.blocks)*int64(fs.bsize)
  433. else
  434. DiskSize:=-1;}
  435. DiskSize := -1;
  436. ConsolePrintf ('warning: fpc sysutils.disksize not implemented'#13#10);
  437. {$warning DiskSize not implemented (does it make sense ?) }
  438. End;
  439. Function GetCurrentDir : String;
  440. begin
  441. GetDir (0,Result);
  442. end;
  443. Function SetCurrentDir (Const NewDir : String) : Boolean;
  444. begin
  445. Libc.FpChDir(pchar(NewDir));
  446. result := (___errno^ = 0);
  447. end;
  448. Function CreateDir (Const NewDir : String) : Boolean;
  449. begin
  450. Libc.FpMkDir(pchar(NewDir),0);
  451. result := (___errno^ = 0);
  452. end;
  453. Function RemoveDir (Const Dir : String) : Boolean;
  454. begin
  455. libc.FpRmDir(pchar(Dir));
  456. result := (___errno^ = 0);
  457. end;
  458. function DirectoryExists (const Directory: string): boolean;
  459. var Info : TStat;
  460. begin
  461. If stat (pchar(Directory),Info) <> 0 then
  462. exit(false)
  463. else
  464. Exit ((Info.st_mode and M_A_SUBDIR) <> 0);
  465. end;
  466. {****************************************************************************
  467. Misc Functions
  468. ****************************************************************************}
  469. procedure Beep;
  470. begin
  471. RingBell;
  472. end;
  473. {****************************************************************************
  474. Locale Functions
  475. ****************************************************************************}
  476. Procedure GetLocalTime(var SystemTime: TSystemTime);
  477. var xx : word;
  478. begin
  479. Dos.GetTime(SystemTime.Hour, SystemTime.Minute, SystemTime.Second, xx);
  480. Dos.GetDate(SystemTime.Year, SystemTime.Month, SystemTime.Day, xx);
  481. SystemTime.MilliSecond := 0;
  482. end;
  483. Procedure InitAnsi;
  484. Var i : longint;
  485. begin
  486. { Fill table entries 0 to 127 }
  487. for i := 0 to 96 do
  488. UpperCaseTable[i] := chr(i);
  489. for i := 97 to 122 do
  490. UpperCaseTable[i] := chr(i - 32);
  491. for i := 123 to 191 do
  492. UpperCaseTable[i] := chr(i);
  493. Move (CPISO88591UCT,UpperCaseTable[192],SizeOf(CPISO88591UCT));
  494. for i := 0 to 64 do
  495. LowerCaseTable[i] := chr(i);
  496. for i := 65 to 90 do
  497. LowerCaseTable[i] := chr(i + 32);
  498. for i := 91 to 191 do
  499. LowerCaseTable[i] := chr(i);
  500. Move (CPISO88591LCT,UpperCaseTable[192],SizeOf(CPISO88591UCT));
  501. end;
  502. Procedure InitInternational;
  503. begin
  504. InitAnsi;
  505. end;
  506. function SysErrorMessage(ErrorCode: Integer): String;
  507. begin
  508. Result:=''; // StrError(ErrorCode);
  509. end;
  510. {****************************************************************************
  511. OS utility functions
  512. ****************************************************************************}
  513. Function GetEnvironmentVariable(Const EnvVar : String) : String;
  514. begin
  515. Result:=StrPas(libc.getenv(PChar(EnvVar)));
  516. end;
  517. function ExecuteProcess(Const Path: AnsiString; Const ComLine: AnsiString):integer;
  518. var
  519. e : EOSError;
  520. CommandLine: AnsiString;
  521. begin
  522. dos.exec(path,comline);
  523. if (Dos.DosError <> 0) then
  524. begin
  525. if ComLine <> '' then
  526. CommandLine := Path + ' ' + ComLine
  527. else
  528. CommandLine := Path;
  529. e:=EOSError.CreateFmt(SExecuteProcessFailed,[CommandLine,Dos.DosError]);
  530. e.ErrorCode:=Dos.DosError;
  531. raise e;
  532. end;
  533. Result := DosExitCode;
  534. end;
  535. function ExecuteProcess (const Path: AnsiString;
  536. const ComLine: array of AnsiString): integer;
  537. var
  538. CommandLine: AnsiString;
  539. I: integer;
  540. begin
  541. Commandline := '';
  542. for I := 0 to High (ComLine) do
  543. if Pos (' ', ComLine [I]) <> 0 then
  544. CommandLine := CommandLine + ' ' + '"' + ComLine [I] + '"'
  545. else
  546. CommandLine := CommandLine + ' ' + Comline [I];
  547. ExecuteProcess := ExecuteProcess (Path, CommandLine);
  548. end;
  549. {****************************************************************************
  550. Initialization code
  551. ****************************************************************************}
  552. Initialization
  553. InitExceptions; { Initialize exceptions. OS independent }
  554. InitInternational; { Initialize internationalization settings }
  555. Finalization
  556. DoneExceptions;
  557. end.
  558. {
  559. $Log$
  560. Revision 1.2 2004-09-12 20:51:22 armin
  561. * added keyboard and video
  562. * a lot of fixes
  563. Revision 1.1 2004/09/05 20:58:47 armin
  564. * first rtl version for netwlibc
  565. }