sysutils.pp 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2000 by Florian Klaempfl
  5. member of the Free Pascal development team
  6. Sysutils unit for OS/2
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. **********************************************************************}
  13. unit sysutils;
  14. interface
  15. {$MODE objfpc}
  16. { force ansistrings }
  17. {$H+}
  18. uses
  19. Dos;
  20. { Include platform independent interface part }
  21. {$i sysutilh.inc}
  22. implementation
  23. { Include platform independent implementation part }
  24. {$i sysutils.inc}
  25. {****************************************************************************
  26. System (imported) calls
  27. ****************************************************************************}
  28. (* "uses DosCalls" could not be used here due to type *)
  29. (* conflicts, so needed parts had to be redefined here). *)
  30. type
  31. TFileStatus = object
  32. end;
  33. PFileStatus = ^TFileStatus;
  34. TFileStatus0 = object (TFileStatus)
  35. DateCreation, {Date of file creation.}
  36. TimeCreation, {Time of file creation.}
  37. DateLastAccess, {Date of last access to file.}
  38. TimeLastAccess, {Time of last access to file.}
  39. DateLastWrite, {Date of last modification of file.}
  40. TimeLastWrite: word; {Time of last modification of file.}
  41. FileSize, {Size of file.}
  42. FileAlloc: cardinal; {Amount of space the file really
  43. occupies on disk.}
  44. end;
  45. PFileStatus0 = ^TFileStatus0;
  46. TFileStatus3 = object (TFileStatus)
  47. NextEntryOffset: cardinal; {Offset of next entry}
  48. DateCreation, {Date of file creation.}
  49. TimeCreation, {Time of file creation.}
  50. DateLastAccess, {Date of last access to file.}
  51. TimeLastAccess, {Time of last access to file.}
  52. DateLastWrite, {Date of last modification of file.}
  53. TimeLastWrite: word; {Time of last modification of file.}
  54. FileSize, {Size of file.}
  55. FileAlloc: cardinal; {Amount of space the file really
  56. occupies on disk.}
  57. AttrFile: cardinal; {Attributes of file.}
  58. end;
  59. PFileStatus3 = ^TFileStatus3;
  60. TFileFindBuf3 = object (TFileStatus3)
  61. Name: ShortString; {Also possible to use as ASCIIZ.
  62. The byte following the last string
  63. character is always zero.}
  64. end;
  65. PFileFindBuf3 = ^TFileFindBuf3;
  66. TFSInfo = record
  67. case word of
  68. 1:
  69. (File_Sys_ID,
  70. Sectors_Per_Cluster,
  71. Total_Clusters,
  72. Free_Clusters: cardinal;
  73. Bytes_Per_Sector: word);
  74. 2: {For date/time description,
  75. see file searching realted
  76. routines.}
  77. (Label_Date, {Date when volume label was created.}
  78. Label_Time: word; {Time when volume label was created.}
  79. VolumeLabel: ShortString); {Volume label. Can also be used
  80. as ASCIIZ, because the byte
  81. following the last character of
  82. the string is always zero.}
  83. end;
  84. PFSInfo = ^TFSInfo;
  85. TCountryCode=record
  86. Country, {Country to query info about (0=current).}
  87. CodePage: cardinal; {Code page to query info about (0=current).}
  88. end;
  89. PCountryCode=^TCountryCode;
  90. TTimeFmt = (Clock12, Clock24);
  91. TCountryInfo=record
  92. Country, CodePage: cardinal; {Country and codepage requested.}
  93. case byte of
  94. 0:
  95. (DateFormat: cardinal; {1=ddmmyy 2=yymmdd 3=mmddyy}
  96. CurrencyUnit: array [0..4] of char;
  97. ThousandSeparator: char; {Thousands separator.}
  98. Zero1: byte; {Always zero.}
  99. DecimalSeparator: char; {Decimals separator,}
  100. Zero2: byte;
  101. DateSeparator: char; {Date separator.}
  102. Zero3: byte;
  103. TimeSeparator: char; {Time separator.}
  104. Zero4: byte;
  105. CurrencyFormat, {Bit field:
  106. Bit 0: 0=indicator before value
  107. 1=indicator after value
  108. Bit 1: 1=insert space after
  109. indicator.
  110. Bit 2: 1=Ignore bit 0&1, replace
  111. decimal separator with
  112. indicator.}
  113. DecimalPlace: byte; {Number of decimal places used in
  114. currency indication.}
  115. TimeFormat: TTimeFmt; {12/24 hour.}
  116. Reserve1: array [0..1] of word;
  117. DataSeparator: char; {Data list separator}
  118. Zero5: byte;
  119. Reserve2: array [0..4] of word);
  120. 1:
  121. (fsDateFmt: cardinal; {1=ddmmyy 2=yymmdd 3=mmddyy}
  122. szCurrency: array [0..4] of char;
  123. {null terminated currency symbol}
  124. szThousandsSeparator: array [0..1] of char;
  125. {Thousands separator + #0}
  126. szDecimal: array [0..1] of char;
  127. {Decimals separator + #0}
  128. szDateSeparator: array [0..1] of char;
  129. {Date separator + #0}
  130. szTimeSeparator: array [0..1] of char;
  131. {Time separator + #0}
  132. fsCurrencyFmt, {Bit field:
  133. Bit 0: 0=indicator before value
  134. 1=indicator after value
  135. Bit 1: 1=insert space after
  136. indicator.
  137. Bit 2: 1=Ignore bit 0&1, replace
  138. decimal separator with
  139. indicator}
  140. cDecimalPlace: byte; {Number of decimal places used in
  141. currency indication}
  142. fsTimeFmt: byte; {0=12,1=24 hours}
  143. abReserved1: array [0..1] of word;
  144. szDataSeparator: array [0..1] of char;
  145. {Data list separator + #0}
  146. abReserved2: array [0..4] of word);
  147. end;
  148. PCountryInfo=^TCountryInfo;
  149. const
  150. ilStandard = 1;
  151. ilQueryEAsize = 2;
  152. ilQueryEAs = 3;
  153. ilQueryFullName = 5;
  154. {This is the correct way to call external assembler procedures.}
  155. procedure syscall;external name '___SYSCALL';
  156. function DosSetFileInfo (Handle: longint; InfoLevel: cardinal; AFileStatus: PFileStatus;
  157. FileStatusLen: cardinal): cardinal; cdecl; external 'DOSCALLS' index 218;
  158. function DosQueryFSInfo (DiskNum, InfoLevel: cardinal; var Buffer: TFSInfo;
  159. BufLen: cardinal): cardinal; cdecl; external 'DOSCALLS' index 278;
  160. function DosQueryFileInfo (Handle: longint; InfoLevel: cardinal;
  161. AFileStatus: PFileStatus; FileStatusLen: cardinal): cardinal; cdecl;
  162. external 'DOSCALLS' index 279;
  163. function DosScanEnv (Name: PChar; var Value: PChar): cardinal; cdecl;
  164. external 'DOSCALLS' index 227;
  165. function DosFindFirst (FileMask: PChar; var Handle: longint; Attrib: cardinal;
  166. AFileStatus: PFileStatus; FileStatusLen: cardinal;
  167. var Count: cardinal; InfoLevel: cardinal): cardinal; cdecl;
  168. external 'DOSCALLS' index 264;
  169. function DosFindNext (Handle: longint; AFileStatus: PFileStatus;
  170. FileStatusLen: cardinal; var Count: cardinal): cardinal; cdecl;
  171. external 'DOSCALLS' index 265;
  172. function DosFindClose (Handle: longint): cardinal; cdecl;
  173. external 'DOSCALLS' index 263;
  174. function DosQueryCtryInfo (Size: cardinal; var Country: TCountryCode;
  175. var Res: TCountryInfo; var ActualSize: cardinal): cardinal; cdecl;
  176. external 'NLS' index 5;
  177. function DosMapCase (Size: cardinal; var Country: TCountryCode;
  178. AString: PChar): cardinal; cdecl; external 'NLS' index 7;
  179. {****************************************************************************
  180. File Functions
  181. ****************************************************************************}
  182. const
  183. ofRead = $0000; {Open for reading}
  184. ofWrite = $0001; {Open for writing}
  185. ofReadWrite = $0002; {Open for reading/writing}
  186. doDenyRW = $0010; {DenyAll (no sharing)}
  187. faCreateNew = $00010000; {Create if file does not exist}
  188. faOpenReplace = $00040000; {Truncate if file exists}
  189. faCreate = $00050000; {Create if file does not exist, truncate otherwise}
  190. FindResvdMask = $00003737; {Allowed bits in attribute
  191. specification for DosFindFirst call.}
  192. {$ASMMODE INTEL}
  193. function FileOpen (const FileName: string; Mode: integer): longint; assembler;
  194. asm
  195. push ebx
  196. mov eax, Mode
  197. (* DenyAll if sharing not specified. *)
  198. test eax, 112
  199. jnz @FOpen1
  200. or eax, 16
  201. @FOpen1:
  202. mov ecx, eax
  203. mov eax, 7F2Bh
  204. mov edx, FileName
  205. call syscall
  206. pop ebx
  207. end {['eax', 'ebx', 'ecx', 'edx']};
  208. function FileCreate (const FileName: string): longint; assembler;
  209. asm
  210. push ebx
  211. mov eax, 7F2Bh
  212. mov ecx, ofReadWrite or faCreate or doDenyRW (* Sharing to DenyAll *)
  213. mov edx, FileName
  214. call syscall
  215. pop ebx
  216. end {['eax', 'ebx', 'ecx', 'edx']};
  217. function FileCreate (const FileName: string; Mode: longint): longint;
  218. begin
  219. FileCreate := FileCreate(FileName);
  220. end;
  221. function FileRead (Handle: longint; var Buffer; Count: longint): longint;
  222. assembler;
  223. asm
  224. push ebx
  225. mov eax, 3F00h
  226. mov ebx, Handle
  227. mov ecx, Count
  228. mov edx, Buffer
  229. call syscall
  230. jnc @FReadEnd
  231. mov eax, -1
  232. @FReadEnd:
  233. pop ebx
  234. end {['eax', 'ebx', 'ecx', 'edx']};
  235. function FileWrite (Handle: longint; const Buffer; Count: longint): longint;
  236. assembler;
  237. asm
  238. push ebx
  239. mov eax, 4000h
  240. mov ebx, Handle
  241. mov ecx, Count
  242. mov edx, Buffer
  243. call syscall
  244. jnc @FWriteEnd
  245. mov eax, -1
  246. @FWriteEnd:
  247. pop ebx
  248. end {['eax', 'ebx', 'ecx', 'edx']};
  249. function FileSeek (Handle, FOffset, Origin: longint): longint; assembler;
  250. asm
  251. push ebx
  252. mov eax, Origin
  253. mov ah, 42h
  254. mov ebx, Handle
  255. mov edx, FOffset
  256. call syscall
  257. jnc @FSeekEnd
  258. mov eax, -1
  259. @FSeekEnd:
  260. pop ebx
  261. end {['eax', 'ebx', 'edx']};
  262. function FileSeek (Handle: longint; FOffset, Origin: Int64): Int64;
  263. begin
  264. {$warning need to add 64bit call }
  265. Result:=FileSeek(Handle,Longint(Foffset),Longint(Origin));
  266. end;
  267. procedure FileClose (Handle: longint); assembler;
  268. asm
  269. push ebx
  270. mov eax, Handle
  271. cmp eax, 2
  272. jbe @FCloseEnd
  273. mov ebx, eax
  274. mov eax, 3E00h
  275. call syscall
  276. @FCloseEnd:
  277. pop ebx
  278. end {['eax', 'ebx']};
  279. function FileTruncate (Handle, Size: longint): boolean; assembler;
  280. asm
  281. push ebx
  282. mov eax, 7F25h
  283. mov ebx, Handle
  284. mov edx, Size
  285. call syscall
  286. jc @FTruncEnd
  287. mov eax, 4202h
  288. mov ebx, Handle
  289. mov edx, 0
  290. call syscall
  291. mov eax, 0
  292. jnc @FTruncEnd
  293. dec eax
  294. @FTruncEnd:
  295. pop ebx
  296. end {['eax', 'ebx', 'ecx', 'edx']};
  297. function FileAge (const FileName: string): longint;
  298. var Handle: longint;
  299. begin
  300. Handle := FileOpen (FileName, 0);
  301. if Handle <> -1 then
  302. begin
  303. Result := FileGetDate (Handle);
  304. FileClose (Handle);
  305. end
  306. else
  307. Result := -1;
  308. end;
  309. function FileExists (const FileName: string): boolean; assembler;
  310. asm
  311. mov ax, 4300h
  312. mov edx, FileName
  313. call syscall
  314. mov eax, 0
  315. jc @FExistsEnd
  316. test cx, 18h
  317. jnz @FExistsEnd
  318. inc eax
  319. @FExistsEnd:
  320. end {['eax', 'ecx', 'edx']};
  321. type TRec = record
  322. T, D: word;
  323. end;
  324. PSearchRec = ^SearchRec;
  325. function FindFirst (const Path: string; Attr: longint; var Rslt: TSearchRec): longint;
  326. var SR: PSearchRec;
  327. FStat: PFileFindBuf3;
  328. Count: cardinal;
  329. Err: cardinal;
  330. begin
  331. New (FStat);
  332. Rslt.FindHandle := $FFFFFFFF;
  333. Count := 1;
  334. Err := DosFindFirst (PChar (Path), Rslt.FindHandle,
  335. Attr and FindResvdMask, FStat, SizeOf (FStat^), Count,
  336. ilStandard);
  337. if (Err = 0) and (Count = 0) then Err := 18;
  338. FindFirst := -Err;
  339. if Err = 0 then
  340. begin
  341. Rslt.Name := FStat^.Name;
  342. Rslt.Size := FStat^.FileSize;
  343. Rslt.Attr := FStat^.AttrFile;
  344. Rslt.ExcludeAttr := 0;
  345. TRec (Rslt.Time).T := FStat^.TimeLastWrite;
  346. TRec (Rslt.Time).D := FStat^.DateLastWrite;
  347. end;
  348. Dispose (FStat);
  349. end;
  350. function FindNext (var Rslt: TSearchRec): longint;
  351. var SR: PSearchRec;
  352. FStat: PFileFindBuf3;
  353. Count: cardinal;
  354. Err: cardinal;
  355. begin
  356. New (FStat);
  357. Count := 1;
  358. Err := DosFindNext (Rslt.FindHandle, FStat, SizeOf (FStat^),
  359. Count);
  360. if (Err = 0) and (Count = 0) then Err := 18;
  361. FindNext := -Err;
  362. if Err = 0 then
  363. begin
  364. Rslt.Name := FStat^.Name;
  365. Rslt.Size := FStat^.FileSize;
  366. Rslt.Attr := FStat^.AttrFile;
  367. Rslt.ExcludeAttr := 0;
  368. TRec (Rslt.Time).T := FStat^.TimeLastWrite;
  369. TRec (Rslt.Time).D := FStat^.DateLastWrite;
  370. end;
  371. Dispose (FStat);
  372. end;
  373. procedure FindClose (var F: TSearchrec);
  374. var SR: PSearchRec;
  375. begin
  376. DosFindClose (F.FindHandle);
  377. F.FindHandle := 0;
  378. end;
  379. function FileGetDate (Handle: longint): longint; assembler;
  380. asm
  381. push ebx
  382. mov ax, 5700h
  383. mov ebx, Handle
  384. call syscall
  385. mov eax, -1
  386. jc @FGetDateEnd
  387. mov ax, dx
  388. shld eax, ecx, 16
  389. @FGetDateEnd:
  390. pop ebx
  391. end {['eax', 'ebx', 'ecx', 'edx']};
  392. function FileSetDate (Handle, Age: longint): longint;
  393. var FStat: PFileStatus0;
  394. RC: cardinal;
  395. begin
  396. New (FStat);
  397. RC := DosQueryFileInfo (Handle, ilStandard, FStat,
  398. SizeOf (FStat^));
  399. if RC <> 0 then
  400. FileSetDate := -1
  401. else
  402. begin
  403. FStat^.DateLastAccess := Hi (Age);
  404. FStat^.DateLastWrite := Hi (Age);
  405. FStat^.TimeLastAccess := Lo (Age);
  406. FStat^.TimeLastWrite := Lo (Age);
  407. RC := DosSetFileInfo (Handle, ilStandard, FStat,
  408. SizeOf (FStat^));
  409. if RC <> 0 then
  410. FileSetDate := -1
  411. else
  412. FileSetDate := 0;
  413. end;
  414. Dispose (FStat);
  415. end;
  416. function FileGetAttr (const FileName: string): longint; assembler;
  417. asm
  418. mov ax, 4300h
  419. mov edx, FileName
  420. call syscall
  421. jnc @FGetAttrEnd
  422. mov eax, -1
  423. @FGetAttrEnd:
  424. end {['eax', 'edx']};
  425. function FileSetAttr (const Filename: string; Attr: longint): longint; assembler;
  426. asm
  427. mov ax, 4301h
  428. mov ecx, Attr
  429. mov edx, FileName
  430. call syscall
  431. mov eax, 0
  432. jnc @FSetAttrEnd
  433. mov eax, -1
  434. @FSetAttrEnd:
  435. end {['eax', 'ecx', 'edx']};
  436. function DeleteFile (const FileName: string): boolean; assembler;
  437. asm
  438. mov ax, 4100h
  439. mov edx, FileName
  440. call syscall
  441. mov eax, 0
  442. jc @FDeleteEnd
  443. inc eax
  444. @FDeleteEnd:
  445. end {['eax', 'edx']};
  446. function RenameFile (const OldName, NewName: string): boolean; assembler;
  447. asm
  448. push edi
  449. mov ax, 5600h
  450. mov edx, OldName
  451. mov edi, NewName
  452. call syscall
  453. mov eax, 0
  454. jc @FRenameEnd
  455. inc eax
  456. @FRenameEnd:
  457. pop edi
  458. end {['eax', 'edx', 'edi']};
  459. {****************************************************************************
  460. Disk Functions
  461. ****************************************************************************}
  462. {$ASMMODE ATT}
  463. function DiskFree (Drive: byte): int64;
  464. var FI: TFSinfo;
  465. RC: cardinal;
  466. begin
  467. {In OS/2, we use the filesystem information.}
  468. RC := DosQueryFSInfo (Drive, 1, FI, SizeOf (FI));
  469. if RC = 0 then
  470. DiskFree := int64 (FI.Free_Clusters) *
  471. int64 (FI.Sectors_Per_Cluster) * int64 (FI.Bytes_Per_Sector)
  472. else
  473. DiskFree := -1;
  474. end;
  475. function DiskSize (Drive: byte): int64;
  476. var FI: TFSinfo;
  477. RC: cardinal;
  478. begin
  479. {In OS/2, we use the filesystem information.}
  480. RC := DosQueryFSinfo (Drive, 1, FI, SizeOf (FI));
  481. if RC = 0 then
  482. DiskSize := int64 (FI.Total_Clusters) *
  483. int64 (FI.Sectors_Per_Cluster) * int64 (FI.Bytes_Per_Sector)
  484. else
  485. DiskSize := -1;
  486. end;
  487. function GetCurrentDir: string;
  488. begin
  489. GetDir (0, Result);
  490. end;
  491. function SetCurrentDir (const NewDir: string): boolean;
  492. begin
  493. {$I-}
  494. ChDir (NewDir);
  495. Result := (IOResult = 0);
  496. {$I+}
  497. end;
  498. function CreateDir (const NewDir: string): boolean;
  499. begin
  500. {$I-}
  501. MkDir (NewDir);
  502. Result := (IOResult = 0);
  503. {$I+}
  504. end;
  505. function RemoveDir (const Dir: string): boolean;
  506. begin
  507. {$I-}
  508. RmDir (Dir);
  509. Result := (IOResult = 0);
  510. {$I+}
  511. end;
  512. {$ASMMODE INTEL}
  513. function DirectoryExists (const Directory: string): boolean; assembler;
  514. asm
  515. mov ax, 4300h
  516. mov edx, Directory
  517. call syscall
  518. mov eax, 0
  519. jc @FExistsEnd
  520. test cx, 10h
  521. jz @FExistsEnd
  522. inc eax
  523. @FExistsEnd:
  524. end {['eax', 'ecx', 'edx']};
  525. {****************************************************************************
  526. Time Functions
  527. ****************************************************************************}
  528. procedure GetLocalTime (var SystemTime: TSystemTime); assembler;
  529. asm
  530. (* Expects the default record alignment (word)!!! *)
  531. push edi
  532. mov ah, 2Ah
  533. call syscall
  534. mov edi, SystemTime
  535. mov ax, cx
  536. stosw
  537. xor eax, eax
  538. mov al, 10
  539. mul dl
  540. shl eax, 16
  541. mov al, dh
  542. stosd
  543. push edi
  544. mov ah, 2Ch
  545. call syscall
  546. pop edi
  547. xor eax, eax
  548. mov al, cl
  549. shl eax, 16
  550. mov al, ch
  551. stosd
  552. mov al, dl
  553. shl eax, 16
  554. mov al, dh
  555. stosd
  556. pop edi
  557. end {['eax', 'ecx', 'edx', 'edi']};
  558. {$asmmode default}
  559. {****************************************************************************
  560. Misc Functions
  561. ****************************************************************************}
  562. procedure Beep;
  563. begin
  564. end;
  565. {****************************************************************************
  566. Locale Functions
  567. ****************************************************************************}
  568. procedure InitAnsi;
  569. var I: byte;
  570. Country: TCountryCode;
  571. begin
  572. for I := 0 to 255 do
  573. UpperCaseTable [I] := Chr (I);
  574. Move (UpperCaseTable, LowerCaseTable, SizeOf (UpperCaseTable));
  575. FillChar (Country, SizeOf (Country), 0);
  576. DosMapCase (SizeOf (UpperCaseTable), Country, @UpperCaseTable);
  577. for I := 0 to 255 do
  578. if UpperCaseTable [I] <> Chr (I) then
  579. LowerCaseTable [Ord (UpperCaseTable [I])] := Chr (I);
  580. end;
  581. procedure InitInternational;
  582. var Country: TCountryCode;
  583. CtryInfo: TCountryInfo;
  584. Size: cardinal;
  585. RC: cardinal;
  586. begin
  587. Size := 0;
  588. FillChar (Country, SizeOf (Country), 0);
  589. FillChar (CtryInfo, SizeOf (CtryInfo), 0);
  590. RC := DosQueryCtryInfo (SizeOf (CtryInfo), Country, CtryInfo, Size);
  591. if RC = 0 then
  592. begin
  593. DateSeparator := CtryInfo.DateSeparator;
  594. case CtryInfo.DateFormat of
  595. 1: begin
  596. ShortDateFormat := 'd/m/y';
  597. LongDateFormat := 'dd" "mmmm" "yyyy';
  598. end;
  599. 2: begin
  600. ShortDateFormat := 'y/m/d';
  601. LongDateFormat := 'yyyy" "mmmm" "dd';
  602. end;
  603. 3: begin
  604. ShortDateFormat := 'm/d/y';
  605. LongDateFormat := 'mmmm" "dd" "yyyy';
  606. end;
  607. end;
  608. TimeSeparator := CtryInfo.TimeSeparator;
  609. DecimalSeparator := CtryInfo.DecimalSeparator;
  610. ThousandSeparator := CtryInfo.ThousandSeparator;
  611. CurrencyFormat := CtryInfo.CurrencyFormat;
  612. CurrencyString := PChar (CtryInfo.CurrencyUnit);
  613. end;
  614. InitAnsi;
  615. end;
  616. function SysErrorMessage(ErrorCode: Integer): String;
  617. begin
  618. Result:=Format(SUnknownErrorCode,[ErrorCode]);
  619. end;
  620. {****************************************************************************
  621. OS Utils
  622. ****************************************************************************}
  623. Function GetEnvironmentVariable(Const EnvVar : String) : String;
  624. begin
  625. GetEnvironmentVariable := StrPas (GetEnvPChar (EnvVar));
  626. end;
  627. {****************************************************************************
  628. Initialization code
  629. ****************************************************************************}
  630. Initialization
  631. InitExceptions; { Initialize exceptions. OS independent }
  632. InitInternational; { Initialize internationalization settings }
  633. Finalization
  634. DoneExceptions;
  635. end.
  636. {
  637. $Log$
  638. Revision 1.34 2003-10-18 16:58:39 hajny
  639. * stdcall fixes again
  640. Revision 1.33 2003/10/13 21:17:31 hajny
  641. * longint to cardinal corrections
  642. Revision 1.32 2003/10/08 05:22:47 yuri
  643. * Some emx code removed
  644. Revision 1.31 2003/10/07 21:26:34 hajny
  645. * stdcall fixes and asm routines cleanup
  646. Revision 1.30 2003/10/03 21:46:41 peter
  647. * stdcall fixes
  648. Revision 1.29 2003/06/06 23:34:40 hajny
  649. * better fix for bug 2518
  650. Revision 1.28 2003/06/06 23:31:17 hajny
  651. * fix for bug 2518 applied to OS/2 as well
  652. Revision 1.27 2003/04/01 15:57:41 peter
  653. * made THandle platform dependent and unique type
  654. Revision 1.26 2003/03/31 02:18:39 yuri
  655. FileClose bug fixed (again ;))
  656. Revision 1.25 2003/03/29 19:14:16 yuri
  657. * Directoryexists function header changed back.
  658. Revision 1.24 2003/03/29 18:53:10 yuri
  659. * Fixed DirectoryExists function header
  660. Revision 1.23 2003/03/29 15:01:20 hajny
  661. + DirectoryExists added for main branch OS/2 too
  662. Revision 1.22 2003/03/01 21:19:14 hajny
  663. * FileClose bug fixed
  664. Revision 1.21 2003/01/04 16:25:08 hajny
  665. * modified to make use of the common GetEnv code
  666. Revision 1.20 2003/01/03 20:41:04 peter
  667. * FileCreate(string,mode) overload added
  668. Revision 1.19 2002/11/18 19:51:00 hajny
  669. * another bunch of type corrections
  670. Revision 1.18 2002/09/23 17:42:37 hajny
  671. * AnsiString to PChar typecast
  672. Revision 1.17 2002/09/07 16:01:25 peter
  673. * old logs removed and tabs fixed
  674. Revision 1.16 2002/07/11 16:00:05 hajny
  675. * FindFirst fix (invalid attribute bits masked out)
  676. Revision 1.15 2002/01/25 16:23:03 peter
  677. * merged filesearch() fix
  678. }