dos.pas 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762
  1. {****************************************************************************
  2. $Id$
  3. Free Pascal Runtime-Library
  4. DOS unit for OS/2
  5. Copyright (c) 1997,1999-2000 by Daniel Mantione,
  6. member of the Free Pascal development team
  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 dos;
  14. {$ASMMODE ATT}
  15. {***************************************************************************}
  16. interface
  17. {***************************************************************************}
  18. {$PACKRECORDS 1}
  19. uses Strings, DosCalls;
  20. const {Bit masks for CPU flags.}
  21. fcarry = $0001;
  22. fparity = $0004;
  23. fauxiliary = $0010;
  24. fzero = $0040;
  25. fsign = $0080;
  26. foverflow = $0800;
  27. {Bit masks for file attributes.}
  28. readonly = $01;
  29. hidden = $02;
  30. sysfile = $04;
  31. volumeid = $08;
  32. directory = $10;
  33. archive = $20;
  34. anyfile = $3F;
  35. fmclosed = $D7B0;
  36. fminput = $D7B1;
  37. fmoutput = $D7B2;
  38. fminout = $D7B3;
  39. type {Some string types:}
  40. comstr=string; {Filenames can be long in OS/2.}
  41. pathstr=string; {String for pathnames.}
  42. dirstr=string; {String for a directory}
  43. namestr=string; {String for a filename.}
  44. extstr=string[40]; {String for an extension. Can be 253
  45. characters long, in theory, but let's
  46. say fourty will be enough.}
  47. {Search record which is used by findfirst and findnext:}
  48. searchrec=record
  49. case boolean of
  50. false: (handle:longint; {Used in os_OS2 mode}
  51. FStat:PFileFindBuf3;
  52. fill2:array[1..21-SizeOf(longint)-SizeOf(pointer)] of byte;
  53. attr2:byte;
  54. time2:longint;
  55. size2:longint;
  56. name2:string); {Filenames can be long in OS/2!}
  57. true: (fill:array[1..21] of byte;
  58. attr:byte;
  59. time:longint;
  60. size:longint;
  61. name:string); {Filenames can be long in OS/2!}
  62. end;
  63. {$i filerec.inc}
  64. {$i textrec.inc}
  65. {Data structure for the registers needed by msdos and intr:}
  66. registers=packed record
  67. case i:integer of
  68. 0:(ax,f1,bx,f2,cx,f3,dx,f4,bp,f5,si,f51,di,f6,ds,f7,es,
  69. f8,flags,fs,gs:word);
  70. 1:(al,ah,f9,f10,bl,bh,f11,f12,cl,ch,f13,f14,dl,dh:byte);
  71. 2:(eax,ebx,ecx,edx,ebp,esi,edi:longint);
  72. end;
  73. {Record for date and time:}
  74. datetime=record
  75. year,month,day,hour,min,sec:word;
  76. end;
  77. {Flags for the exec procedure:
  78. Starting the program:
  79. efwait: Wait until program terminates.
  80. efno_wait: Don't wait until the program terminates. Does not work
  81. in dos, as DOS cannot multitask.
  82. efoverlay: Terminate this program, then execute the requested
  83. program. WARNING: Exit-procedures are not called!
  84. efdebug: Debug program. Details are unknown.
  85. efsession: Do not execute as child of this program. Use a seperate
  86. session instead.
  87. efdetach: Detached. Function unknown. Info wanted!
  88. efpm: Run as presentation manager program.
  89. Not found info about execwinflags
  90. Determining the window state of the program:
  91. efdefault: Run the pm program in it's default situation.
  92. efminimize: Run the pm program minimized.
  93. efmaximize: Run the pm program maximized.
  94. effullscreen: Run the non-pm program fullscreen.
  95. efwindowed: Run the non-pm program in a window.
  96. }
  97. type execrunflags=(efwait,efno_wait,efoverlay,efdebug,efsession,
  98. efdetach,efpm);
  99. execwinflags=(efdefault,efminimize,efmaximize,effullscreen,
  100. efwindowed);
  101. const
  102. (* For compatibility with VP/2, used for runflags in Exec procedure. *)
  103. ExecFlags: cardinal = ord (efwait);
  104. var doserror:integer;
  105. dosexitcode:word;
  106. procedure getdate(var year,month,day,dayofweek:word);
  107. procedure gettime(var hour,minute,second,sec100:word);
  108. function dosversion:word;
  109. procedure setdate(year,month,day:word);
  110. procedure settime(hour,minute,second,sec100:word);
  111. procedure getcbreak(var breakvalue:boolean);
  112. procedure setcbreak(breakvalue:boolean);
  113. procedure getverify(var verify:boolean);
  114. procedure setverify(verify : boolean);
  115. function DiskFree (Drive: byte) : int64;
  116. function DiskSize (Drive: byte) : int64;
  117. procedure findfirst(const path:pathstr;attr:word;var f:searchRec);
  118. procedure findnext(var f:searchRec);
  119. procedure findclose(var f:searchRec);
  120. {Is a dummy:}
  121. procedure swapvectors;
  122. {Not supported:
  123. procedure getintvec(intno:byte;var vector:pointer);
  124. procedure setintvec(intno:byte;vector:pointer);
  125. procedure keep(exitcode:word);
  126. procedure msdos(var regs:registers);
  127. procedure intr(intno : byte;var regs:registers);
  128. }
  129. procedure getfattr(var f;var attr:word);
  130. procedure setfattr(var f;attr:word);
  131. function fsearch(path:pathstr;dirlist:string):pathstr;
  132. procedure getftime(var f;var time:longint);
  133. procedure setftime(var f;time:longint);
  134. procedure packtime (var d:datetime; var time:longint);
  135. procedure unpacktime (time:longint; var d:datetime);
  136. function fexpand(const path:pathstr):pathstr;
  137. procedure fsplit(path:pathstr;var dir:dirstr;var name:namestr;
  138. var ext:extstr);
  139. procedure exec(const path:pathstr;const comline:comstr);
  140. function exec(path:pathstr;runflags:execrunflags;winflags:execwinflags;
  141. const comline:comstr):longint;
  142. function envcount:longint;
  143. function envstr(index:longint) : string;
  144. function GetEnvPChar (EnvVar: string): PChar;
  145. function getenv(const envvar:string): string;
  146. implementation
  147. var LastSR: SearchRec;
  148. type TBA = array [1..SizeOf (SearchRec)] of byte;
  149. PBA = ^TBA;
  150. const FindResvdMask = $00003737; {Allowed bits in attribute
  151. specification for DosFindFirst call.}
  152. function fsearch(path:pathstr;dirlist:string):pathstr;
  153. Var
  154. A: array [0..255] of char;
  155. D, P: AnsiString;
  156. begin
  157. P:=Path;
  158. D:=DirList;
  159. DosError:=DosSearchPath(0, PChar(D), PChar(P), @A, 255);
  160. fsearch := StrPas (@A);
  161. end;
  162. procedure getftime(var f;var time:longint);
  163. var
  164. FStat: TFileStatus3;
  165. begin
  166. DosError := DosQueryFileInfo (FileRec (F).Handle, ilStandard, @FStat,
  167. SizeOf (FStat));
  168. if DosError=0 then
  169. begin
  170. Time := FStat.TimeLastWrite + longint (FStat.DateLastWrite) shl 16;
  171. if Time = 0 then
  172. Time := FStat.TimeCreation + longint (FStat.DateCreation) shl 16;
  173. end else
  174. Time:=0;
  175. end;
  176. procedure SetFTime (var F; Time: longint);
  177. var FStat: TFileStatus3;
  178. RC: cardinal;
  179. begin
  180. RC := DosQueryFileInfo (FileRec (F).Handle, ilStandard, @FStat,
  181. SizeOf (FStat));
  182. if RC = 0 then
  183. begin
  184. FStat.DateLastAccess := Hi (Time);
  185. FStat.DateLastWrite := Hi (Time);
  186. FStat.TimeLastAccess := Lo (Time);
  187. FStat.TimeLastWrite := Lo (Time);
  188. RC := DosSetFileInfo (FileRec (F).Handle, ilStandard, @FStat,
  189. SizeOf (FStat));
  190. end;
  191. DosError := integer (RC);
  192. end;
  193. procedure exec(const path:pathstr;const comline:comstr);
  194. {Execute a program.}
  195. begin
  196. dosexitcode:=word(exec(path,execrunflags(ExecFlags),efdefault,comline));
  197. end;
  198. function exec(path:pathstr;runflags:execrunflags;winflags:execwinflags;
  199. const comline:comstr):longint;
  200. {Execute a program. More suitable for OS/2 than the exec above.}
  201. var args:Pbytearray;
  202. env:Pbytearray;
  203. i,argsize:word;
  204. esadr:pointer;
  205. d:dirstr;
  206. n:namestr;
  207. e:extstr;
  208. p : ppchar;
  209. j : integer;
  210. res: TResultCodes;
  211. ObjName: String;
  212. const
  213. ArgsSize = 2048; (* Amount of memory reserved for arguments in bytes. *)
  214. begin
  215. getmem(args,ArgsSize);
  216. GetMem(env, envc*sizeof(pchar)+16384);
  217. {Now setup the arguments. The first argument should be the program
  218. name without directory and extension.}
  219. fsplit(path,d,n,e);
  220. // args^[0]:=$80;
  221. argsize:=0;
  222. for i:=1 to length(n) do
  223. begin
  224. args^[argsize]:=byte(n[i]);
  225. inc(argsize);
  226. end;
  227. args^[argsize]:=0;
  228. inc(argsize);
  229. {Now do the real arguments.}
  230. i:=1;
  231. while i<=length(comline) do
  232. begin
  233. if comline[i]<>' ' then
  234. begin
  235. {Commandline argument found. Copy it.}
  236. // args^[argsize]:=$80;
  237. // inc(argsize);
  238. while (i<=length(comline)) and (comline[i]<>' ') do
  239. begin
  240. args^[argsize]:=byte(comline[i]);
  241. inc(argsize);
  242. inc(i);
  243. end;
  244. args^[argsize]:=32;//0;
  245. inc(argsize);
  246. end;
  247. inc(i);
  248. end;
  249. args^[argsize]:=0;
  250. inc(argsize);
  251. {Commandline ready, now build the environment.
  252. Oh boy, I always had the opinion that executing a program under Dos
  253. was a hard job!}
  254. asm
  255. movl env,%edi {Setup destination pointer.}
  256. movl envc,%ecx {Load number of arguments in edx.}
  257. movl envp,%esi {Load env. strings.}
  258. xorl %edx,%edx {Count environment size.}
  259. .Lexa1:
  260. lodsl {Load a Pchar.}
  261. xchgl %eax,%ebx
  262. .Lexa2:
  263. movb (%ebx),%al {Load a byte.}
  264. incl %ebx {Point to next byte.}
  265. stosb {Store it.}
  266. incl %edx {Increase counter.}
  267. cmpb $0,%al {Ready ?.}
  268. jne .Lexa2
  269. loop .Lexa1 {Next argument.}
  270. stosb {Store an extra 0 to finish. (AL is now 0).}
  271. incl %edx
  272. // movw %dx,ES.SizeEnv {Store environment size.}
  273. end ['eax','ebx','ecx','edx','esi','edi'];
  274. //Not clear how to use
  275. DosError:=DosExecPgm(ObjName, cardinal (RunFlags), Args, Env, Res, Path);
  276. exec:=Res.ExitCode;
  277. freemem(args,ArgsSize);
  278. FreeMem(env, envc*sizeof(pchar)+16384);
  279. {Phew! That's it. This was the most sophisticated procedure to call
  280. a system function I ever wrote!}
  281. end;
  282. function dosversion:word;
  283. {Returns OS/2 version}
  284. var
  285. Minor, Major: Cardinal;
  286. begin
  287. DosQuerySysInfo(svMajorVersion, svMajorVersion, Major, 4);
  288. DosQuerySysInfo(svMinorVersion, svMinorVersion, Minor, 4);
  289. DosVersion:=Major or Minor shl 8;
  290. end;
  291. procedure GetDate (var Year, Month, Day, DayOfWeek: word);
  292. Var
  293. dt: TDateTime;
  294. begin
  295. DosGetDateTime(dt);
  296. Year:=dt.year;
  297. Month:=dt.month;
  298. Day:=dt.Day;
  299. DayofWeek:=dt.Weekday;
  300. end;
  301. procedure SetDate (Year, Month, Day: word);
  302. var
  303. DT: TDateTime;
  304. begin
  305. DosGetDateTime (DT);
  306. DT.Year := Year;
  307. DT.Month := byte (Month);
  308. DT.Day := byte (Day);
  309. DosSetDateTime (DT);
  310. end;
  311. procedure GetTime (var Hour, Minute, Second, Sec100: word);
  312. var
  313. dt: TDateTime;
  314. begin
  315. DosGetDateTime(dt);
  316. Hour:=dt.Hour;
  317. Minute:=dt.Minute;
  318. Second:=dt.Second;
  319. Sec100:=dt.Hundredths;
  320. end;
  321. procedure SetTime (Hour, Minute, Second, Sec100: word);
  322. var
  323. DT: TDateTime;
  324. begin
  325. DosGetDateTime (DT);
  326. DT.Hour := byte (Hour);
  327. DT.Minute := byte (Minute);
  328. DT.Second := byte (Second);
  329. DT.Sec100 := byte (Sec100);
  330. DosSetDateTime (DT);
  331. end;
  332. procedure getcbreak(var breakvalue:boolean);
  333. begin
  334. breakvalue := True;
  335. end;
  336. procedure setcbreak(breakvalue:boolean);
  337. begin
  338. end;
  339. procedure getverify(var verify:boolean);
  340. begin
  341. verify := true;
  342. end;
  343. procedure setverify(verify:boolean);
  344. begin
  345. end;
  346. function DiskFree (Drive: byte): int64;
  347. var FI: TFSinfo;
  348. RC: cardinal;
  349. begin
  350. {In OS/2, we use the filesystem information.}
  351. RC := DosQueryFSInfo (Drive, 1, FI, SizeOf (FI));
  352. if RC = 0 then
  353. DiskFree := int64 (FI.Free_Clusters) *
  354. int64 (FI.Sectors_Per_Cluster) * int64 (FI.Bytes_Per_Sector)
  355. else
  356. DiskFree := -1;
  357. end;
  358. function DiskSize (Drive: byte): int64;
  359. var FI: TFSinfo;
  360. RC: cardinal;
  361. begin
  362. RC := DosQueryFSinfo (Drive, 1, FI, SizeOf (FI));
  363. if RC = 0 then
  364. DiskSize := int64 (FI.Total_Clusters) *
  365. int64 (FI.Sectors_Per_Cluster) * int64 (FI.Bytes_Per_Sector)
  366. else
  367. DiskSize := -1;
  368. end;
  369. procedure SearchRec2DosSearchRec (var F: SearchRec);
  370. begin
  371. end;
  372. procedure DosSearchRec2SearchRec (var F: SearchRec);
  373. type
  374. TRec = record
  375. T, D: word;
  376. end;
  377. begin
  378. with F do
  379. begin
  380. Name := FStat^.Name;
  381. Size := FStat^.FileSize;
  382. Attr := byte(FStat^.AttrFile and $FF);
  383. TRec (Time).T := FStat^.TimeLastWrite;
  384. TRec (Time).D := FStat^.DateLastWrite;
  385. end;
  386. end;
  387. procedure FindFirst (const Path: PathStr; Attr: word; var F: SearchRec);
  388. var Count: cardinal;
  389. begin
  390. {No error.}
  391. DosError := 0;
  392. New (F.FStat);
  393. F.Handle := longint ($FFFFFFFF);
  394. Count := 1;
  395. DosError := integer (DosFindFirst (Path, F.Handle,
  396. Attr and FindResvdMask, F.FStat, SizeOf (F.FStat^),
  397. Count, ilStandard));
  398. if (DosError = 0) and (Count = 0) then DosError := 18;
  399. DosSearchRec2SearchRec (F);
  400. end;
  401. procedure FindNext (var F: SearchRec);
  402. var
  403. Count: cardinal;
  404. begin
  405. {No error}
  406. DosError := 0;
  407. SearchRec2DosSearchRec (F);
  408. Count := 1;
  409. DosError := integer (DosFindNext (F.Handle, F.FStat, SizeOf (F.FStat^),
  410. Count));
  411. if (DosError = 0) and (Count = 0) then DosError := 18;
  412. DosSearchRec2SearchRec (F);
  413. end;
  414. procedure FindClose (var F: SearchRec);
  415. begin
  416. if F.Handle <> $FFFFFFFF then DosError := DosFindClose (F.Handle);
  417. Dispose (F.FStat);
  418. end;
  419. procedure swapvectors;
  420. {For TP compatibility, this exists.}
  421. begin
  422. end;
  423. function envcount:longint;
  424. begin
  425. envcount:=envc;
  426. end;
  427. function envstr(index : longint) : string;
  428. var hp:Pchar;
  429. begin
  430. if (index<=0) or (index>envcount) then
  431. begin
  432. envstr:='';
  433. exit;
  434. end;
  435. hp:=EnvP[index-1];
  436. envstr:=strpas(hp);
  437. end;
  438. function GetEnvPChar (EnvVar: string): PChar;
  439. (* The assembler version is more than three times as fast as Pascal. *)
  440. var
  441. P: PChar;
  442. begin
  443. EnvVar := UpCase (EnvVar);
  444. {$ASMMODE INTEL}
  445. asm
  446. cld
  447. mov edi, Environment
  448. lea esi, EnvVar
  449. xor eax, eax
  450. lodsb
  451. @NewVar:
  452. cmp byte ptr [edi], 0
  453. jz @Stop
  454. push eax { eax contains length of searched variable name }
  455. push esi { esi points to the beginning of the variable name }
  456. mov ecx, -1 { our character ('=' - see below) _must_ be found }
  457. mov edx, edi { pointer to beginning of variable name saved in edx }
  458. mov al, '=' { searching until '=' (end of variable name) }
  459. repne
  460. scasb { scan until '=' not found }
  461. neg ecx { what was the name length? }
  462. dec ecx { corrected }
  463. dec ecx { exclude the '=' character }
  464. pop esi { restore pointer to beginning of variable name }
  465. pop eax { restore length of searched variable name }
  466. push eax { and save both of them again for later use }
  467. push esi
  468. cmp ecx, eax { compare length of searched variable name with name }
  469. jnz @NotEqual { ... of currently found variable, jump if different }
  470. xchg edx, edi { pointer to current variable name restored in edi }
  471. repe
  472. cmpsb { compare till the end of variable name }
  473. xchg edx, edi { pointer to beginning of variable contents in edi }
  474. jz @Equal { finish if they're equal }
  475. @NotEqual:
  476. xor eax, eax { look for 00h }
  477. mov ecx, -1 { it _must_ be found }
  478. repne
  479. scasb { scan until found }
  480. pop esi { restore pointer to beginning of variable name }
  481. pop eax { restore length of searched variable name }
  482. jmp @NewVar { ... or continue with new variable otherwise }
  483. @Stop:
  484. xor eax, eax
  485. mov P, eax { Not found - return nil }
  486. jmp @End
  487. @Equal:
  488. pop esi { restore the stack position }
  489. pop eax
  490. mov P, edi { place pointer to variable contents in P }
  491. @End:
  492. end ['eax','ecx','edx','esi','edi'];
  493. GetEnvPChar := P;
  494. end;
  495. {$ASMMODE ATT}
  496. function GetEnv (const EnvVar: string): string;
  497. (* The assembler version is more than three times as fast as Pascal. *)
  498. begin
  499. GetEnv := StrPas (GetEnvPChar (EnvVar));
  500. end;
  501. procedure fsplit(path:pathstr;var dir:dirstr;var name:namestr;
  502. var ext:extstr);
  503. var p1,i : longint;
  504. dotpos : integer;
  505. begin
  506. { allow slash as backslash }
  507. for i:=1 to length(path) do
  508. if path[i]='/' then path[i]:='\';
  509. {Get drive name}
  510. p1:=pos(':',path);
  511. if p1>0 then
  512. begin
  513. dir:=path[1]+':';
  514. delete(path,1,p1);
  515. end
  516. else
  517. dir:='';
  518. { split the path and the name, there are no more path informtions }
  519. { if path contains no backslashes }
  520. while true do
  521. begin
  522. p1:=pos('\',path);
  523. if p1=0 then
  524. break;
  525. dir:=dir+copy(path,1,p1);
  526. delete(path,1,p1);
  527. end;
  528. { try to find out a extension }
  529. Ext:='';
  530. i:=Length(Path);
  531. DotPos:=256;
  532. While (i>0) Do
  533. Begin
  534. If (Path[i]='.') Then
  535. begin
  536. DotPos:=i;
  537. break;
  538. end;
  539. Dec(i);
  540. end;
  541. Ext:=Copy(Path,DotPos,255);
  542. Name:=Copy(Path,1,DotPos - 1);
  543. end;
  544. (*
  545. function FExpand (const Path: PathStr): PathStr;
  546. - declared in fexpand.inc
  547. *)
  548. {$DEFINE FPC_FEXPAND_UNC} (* UNC paths are supported *)
  549. {$DEFINE FPC_FEXPAND_DRIVES} (* Full paths begin with drive specification *)
  550. {$I fexpand.inc}
  551. {$UNDEF FPC_FEXPAND_DRIVES}
  552. {$UNDEF FPC_FEXPAND_UNC}
  553. procedure packtime(var d:datetime;var time:longint);
  554. var zs:longint;
  555. begin
  556. time:=-1980;
  557. time:=time+d.year and 127;
  558. time:=time shl 4;
  559. time:=time+d.month;
  560. time:=time shl 5;
  561. time:=time+d.day;
  562. time:=time shl 16;
  563. zs:=d.hour;
  564. zs:=zs shl 6;
  565. zs:=zs+d.min;
  566. zs:=zs shl 5;
  567. zs:=zs+d.sec div 2;
  568. time:=time+(zs and $ffff);
  569. end;
  570. procedure unpacktime (time:longint;var d:datetime);
  571. begin
  572. d.sec:=(time and 31) * 2;
  573. time:=time shr 5;
  574. d.min:=time and 63;
  575. time:=time shr 6;
  576. d.hour:=time and 31;
  577. time:=time shr 5;
  578. d.day:=time and 31;
  579. time:=time shr 5;
  580. d.month:=time and 15;
  581. time:=time shr 4;
  582. d.year:=time+1980;
  583. end;
  584. procedure GetFAttr (var F; var Attr: word);
  585. var
  586. PathInfo: TFileStatus3;
  587. RC: cardinal;
  588. begin
  589. Attr := 0;
  590. RC := DosQueryPathInfo (FileRec (F).Name, ilStandard,
  591. @PathInfo, SizeOf (PathInfo));
  592. DosError := integer (RC);
  593. if RC = 0 then
  594. Attr := PathInfo.AttrFile;
  595. end;
  596. procedure SetFAttr (var F; Attr: word);
  597. var
  598. PathInfo: TFileStatus3;
  599. RC: cardinal;
  600. begin
  601. RC := DosQueryPathInfo (FileRec (F).Name, ilStandard,
  602. @PathInfo, SizeOf (PathInfo));
  603. if RC = 0 then
  604. begin
  605. PathInfo.AttrFile := Attr;
  606. RC := DosSetPathInfo (FileRec (F).Name, ilStandard, @PathInfo,
  607. SizeOf (PathInfo), doWriteThru);
  608. end;
  609. DosError := integer (RC);
  610. end;
  611. end.
  612. {
  613. $Log$
  614. Revision 1.33 2003-11-05 09:13:59 yuri
  615. * exec fix
  616. * unused units removed
  617. Revision 1.32 2003/11/02 09:45:32 hajny
  618. SetFTime fix
  619. Revision 1.31 2003/11/01 18:35:12 hajny
  620. * GetFTime correction for case of no previous write access
  621. Revision 1.30 2003/10/25 23:55:22 hajny
  622. * Exec fix
  623. Revision 1.29 2003/10/25 22:45:37 hajny
  624. * file handling related fixes
  625. Revision 1.28 2003/10/05 22:06:43 hajny
  626. * result buffers must be allocated
  627. Revision 1.27 2003/10/03 21:46:41 peter
  628. * stdcall fixes
  629. Revision 1.26 2003/09/24 08:59:16 yuri
  630. * Prepared for native target (emx code replaced)
  631. Revision 1.25 2003/02/20 17:37:00 hajny
  632. * correction for previous mistyping
  633. Revision 1.24 2003/02/20 17:09:49 hajny
  634. * fixes for OS/2 v2.1 incompatibility
  635. Revision 1.23 2003/01/04 15:43:50 hajny
  636. + GetEnvPChar added
  637. Revision 1.22 2002/12/07 19:46:56 hajny
  638. * mistyping fixed
  639. Revision 1.21 2002/12/07 19:17:13 hajny
  640. * GetEnv correction, better PM support, ...
  641. Revision 1.20 2002/11/18 19:51:00 hajny
  642. * another bunch of type corrections
  643. Revision 1.19 2002/09/07 16:01:24 peter
  644. * old logs removed and tabs fixed
  645. Revision 1.18 2002/07/11 16:00:05 hajny
  646. * FindFirst fix (invalid attribute bits masked out)
  647. Revision 1.17 2002/07/07 18:00:48 hajny
  648. * DosGetInfoBlock modification to allow overloaded version (in DosCalls)
  649. Revision 1.16 2002/03/03 11:19:20 hajny
  650. * GetEnv rewritten to assembly - 3x faster now
  651. }