2
0

dos.pas 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756
  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. exec:=DosExecPgm(ObjName, cardinal (RunFlags), Args, Env, Res, Path);
  276. freemem(args,ArgsSize);
  277. FreeMem(env, envc*sizeof(pchar)+16384);
  278. {Phew! That's it. This was the most sophisticated procedure to call
  279. a system function I ever wrote!}
  280. end;
  281. function dosversion:word;
  282. {Returns OS/2 version}
  283. var
  284. Minor, Major: Cardinal;
  285. begin
  286. DosQuerySysInfo(svMajorVersion, svMajorVersion, Major, 4);
  287. DosQuerySysInfo(svMinorVersion, svMinorVersion, Minor, 4);
  288. DosVersion:=Major or Minor shl 8;
  289. end;
  290. procedure GetDate (var Year, Month, Day, DayOfWeek: word);
  291. Var
  292. dt: TDateTime;
  293. begin
  294. DosGetDateTime(dt);
  295. Year:=dt.year;
  296. Month:=dt.month;
  297. Day:=dt.Day;
  298. DayofWeek:=dt.Weekday;
  299. end;
  300. procedure SetDate (Year, Month, Day: word);
  301. var
  302. DT: TDateTime;
  303. begin
  304. DosGetDateTime (DT);
  305. DT.Year := Year;
  306. DT.Month := byte (Month);
  307. DT.Day := byte (Day);
  308. DosSetDateTime (DT);
  309. end;
  310. procedure GetTime (var Hour, Minute, Second, Sec100: word);
  311. var
  312. dt: TDateTime;
  313. begin
  314. DosGetDateTime(dt);
  315. Hour:=dt.Hour;
  316. Minute:=dt.Minute;
  317. Second:=dt.Second;
  318. Sec100:=dt.Hundredths;
  319. end;
  320. procedure SetTime (Hour, Minute, Second, Sec100: word);
  321. var
  322. DT: TDateTime;
  323. begin
  324. DosGetDateTime (DT);
  325. DT.Hour := byte (Hour);
  326. DT.Minute := byte (Minute);
  327. DT.Second := byte (Second);
  328. DT.Sec100 := byte (Sec100);
  329. DosSetDateTime (DT);
  330. end;
  331. procedure getcbreak(var breakvalue:boolean);
  332. begin
  333. breakvalue := True;
  334. end;
  335. procedure setcbreak(breakvalue:boolean);
  336. begin
  337. end;
  338. procedure getverify(var verify:boolean);
  339. begin
  340. verify := true;
  341. end;
  342. procedure setverify(verify:boolean);
  343. begin
  344. end;
  345. function DiskFree (Drive: byte): int64;
  346. var FI: TFSinfo;
  347. RC: cardinal;
  348. begin
  349. {In OS/2, we use the filesystem information.}
  350. RC := DosQueryFSInfo (Drive, 1, FI, SizeOf (FI));
  351. if RC = 0 then
  352. DiskFree := int64 (FI.Free_Clusters) *
  353. int64 (FI.Sectors_Per_Cluster) * int64 (FI.Bytes_Per_Sector)
  354. else
  355. DiskFree := -1;
  356. end;
  357. function DiskSize (Drive: byte): int64;
  358. var FI: TFSinfo;
  359. RC: cardinal;
  360. begin
  361. RC := DosQueryFSinfo (Drive, 1, FI, SizeOf (FI));
  362. if RC = 0 then
  363. DiskSize := int64 (FI.Total_Clusters) *
  364. int64 (FI.Sectors_Per_Cluster) * int64 (FI.Bytes_Per_Sector)
  365. else
  366. DiskSize := -1;
  367. end;
  368. procedure SearchRec2DosSearchRec (var F: SearchRec);
  369. begin
  370. end;
  371. procedure DosSearchRec2SearchRec (var F: SearchRec);
  372. type
  373. TRec = record
  374. T, D: word;
  375. end;
  376. begin
  377. with F do
  378. begin
  379. Name := FStat^.Name;
  380. Size := FStat^.FileSize;
  381. Attr := byte(FStat^.AttrFile and $FF);
  382. TRec (Time).T := FStat^.TimeLastWrite;
  383. TRec (Time).D := FStat^.DateLastWrite;
  384. end;
  385. end;
  386. procedure FindFirst (const Path: PathStr; Attr: word; var F: SearchRec);
  387. var Count: cardinal;
  388. begin
  389. {No error.}
  390. DosError := 0;
  391. New (F.FStat);
  392. F.Handle := longint ($FFFFFFFF);
  393. Count := 1;
  394. DosError := integer (DosFindFirst (Path, F.Handle,
  395. Attr and FindResvdMask, F.FStat, SizeOf (F.FStat^),
  396. Count, ilStandard));
  397. if (DosError = 0) and (Count = 0) then DosError := 18;
  398. DosSearchRec2SearchRec (F);
  399. end;
  400. procedure FindNext (var F: SearchRec);
  401. var
  402. Count: cardinal;
  403. begin
  404. {No error}
  405. DosError := 0;
  406. SearchRec2DosSearchRec (F);
  407. Count := 1;
  408. DosError := integer (DosFindNext (F.Handle, F.FStat, SizeOf (F.FStat^),
  409. Count));
  410. if (DosError = 0) and (Count = 0) then DosError := 18;
  411. DosSearchRec2SearchRec (F);
  412. end;
  413. procedure FindClose (var F: SearchRec);
  414. begin
  415. if F.Handle <> $FFFFFFFF then DosError := DosFindClose (F.Handle);
  416. Dispose (F.FStat);
  417. end;
  418. procedure swapvectors;
  419. {For TP compatibility, this exists.}
  420. begin
  421. end;
  422. function envcount:longint;
  423. begin
  424. envcount:=envc;
  425. end;
  426. function envstr(index : longint) : string;
  427. var hp:Pchar;
  428. begin
  429. if (index<=0) or (index>envcount) then
  430. begin
  431. envstr:='';
  432. exit;
  433. end;
  434. hp:=EnvP[index-1];
  435. envstr:=strpas(hp);
  436. end;
  437. function GetEnvPChar (EnvVar: string): PChar;
  438. (* The assembler version is more than three times as fast as Pascal. *)
  439. var
  440. P: PChar;
  441. begin
  442. EnvVar := UpCase (EnvVar);
  443. {$ASMMODE INTEL}
  444. asm
  445. cld
  446. mov edi, Environment
  447. lea esi, EnvVar
  448. xor eax, eax
  449. lodsb
  450. @NewVar:
  451. cmp byte ptr [edi], 0
  452. jz @Stop
  453. push eax { eax contains length of searched variable name }
  454. push esi { esi points to the beginning of the variable name }
  455. mov ecx, -1 { our character ('=' - see below) _must_ be found }
  456. mov edx, edi { pointer to beginning of variable name saved in edx }
  457. mov al, '=' { searching until '=' (end of variable name) }
  458. repne
  459. scasb { scan until '=' not found }
  460. neg ecx { what was the name length? }
  461. dec ecx { corrected }
  462. dec ecx { exclude the '=' character }
  463. pop esi { restore pointer to beginning of variable name }
  464. pop eax { restore length of searched variable name }
  465. push eax { and save both of them again for later use }
  466. push esi
  467. cmp ecx, eax { compare length of searched variable name with name }
  468. jnz @NotEqual { ... of currently found variable, jump if different }
  469. xchg edx, edi { pointer to current variable name restored in edi }
  470. repe
  471. cmpsb { compare till the end of variable name }
  472. xchg edx, edi { pointer to beginning of variable contents in edi }
  473. jz @Equal { finish if they're equal }
  474. @NotEqual:
  475. xor eax, eax { look for 00h }
  476. mov ecx, -1 { it _must_ be found }
  477. repne
  478. scasb { scan until found }
  479. pop esi { restore pointer to beginning of variable name }
  480. pop eax { restore length of searched variable name }
  481. jmp @NewVar { ... or continue with new variable otherwise }
  482. @Stop:
  483. xor eax, eax
  484. mov P, eax { Not found - return nil }
  485. jmp @End
  486. @Equal:
  487. pop esi { restore the stack position }
  488. pop eax
  489. mov P, edi { place pointer to variable contents in P }
  490. @End:
  491. end ['eax','ecx','edx','esi','edi'];
  492. GetEnvPChar := P;
  493. end;
  494. {$ASMMODE ATT}
  495. function GetEnv (const EnvVar: string): string;
  496. (* The assembler version is more than three times as fast as Pascal. *)
  497. begin
  498. GetEnv := StrPas (GetEnvPChar (EnvVar));
  499. end;
  500. procedure fsplit(path:pathstr;var dir:dirstr;var name:namestr;
  501. var ext:extstr);
  502. var p1,i : longint;
  503. dotpos : integer;
  504. begin
  505. { allow slash as backslash }
  506. for i:=1 to length(path) do
  507. if path[i]='/' then path[i]:='\';
  508. {Get drive name}
  509. p1:=pos(':',path);
  510. if p1>0 then
  511. begin
  512. dir:=path[1]+':';
  513. delete(path,1,p1);
  514. end
  515. else
  516. dir:='';
  517. { split the path and the name, there are no more path informtions }
  518. { if path contains no backslashes }
  519. while true do
  520. begin
  521. p1:=pos('\',path);
  522. if p1=0 then
  523. break;
  524. dir:=dir+copy(path,1,p1);
  525. delete(path,1,p1);
  526. end;
  527. { try to find out a extension }
  528. Ext:='';
  529. i:=Length(Path);
  530. DotPos:=256;
  531. While (i>0) Do
  532. Begin
  533. If (Path[i]='.') Then
  534. begin
  535. DotPos:=i;
  536. break;
  537. end;
  538. Dec(i);
  539. end;
  540. Ext:=Copy(Path,DotPos,255);
  541. Name:=Copy(Path,1,DotPos - 1);
  542. end;
  543. (*
  544. function FExpand (const Path: PathStr): PathStr;
  545. - declared in fexpand.inc
  546. *)
  547. {$DEFINE FPC_FEXPAND_UNC} (* UNC paths are supported *)
  548. {$DEFINE FPC_FEXPAND_DRIVES} (* Full paths begin with drive specification *)
  549. {$I fexpand.inc}
  550. {$UNDEF FPC_FEXPAND_DRIVES}
  551. {$UNDEF FPC_FEXPAND_UNC}
  552. procedure packtime(var d:datetime;var time:longint);
  553. var zs:longint;
  554. begin
  555. time:=-1980;
  556. time:=time+d.year and 127;
  557. time:=time shl 4;
  558. time:=time+d.month;
  559. time:=time shl 5;
  560. time:=time+d.day;
  561. time:=time shl 16;
  562. zs:=d.hour;
  563. zs:=zs shl 6;
  564. zs:=zs+d.min;
  565. zs:=zs shl 5;
  566. zs:=zs+d.sec div 2;
  567. time:=time+(zs and $ffff);
  568. end;
  569. procedure unpacktime (time:longint;var d:datetime);
  570. begin
  571. d.sec:=(time and 31) * 2;
  572. time:=time shr 5;
  573. d.min:=time and 63;
  574. time:=time shr 6;
  575. d.hour:=time and 31;
  576. time:=time shr 5;
  577. d.day:=time and 31;
  578. time:=time shr 5;
  579. d.month:=time and 15;
  580. time:=time shr 4;
  581. d.year:=time+1980;
  582. end;
  583. procedure GetFAttr (var F; var Attr: word);
  584. var
  585. PathInfo: TFileStatus3;
  586. RC: cardinal;
  587. begin
  588. Attr := 0;
  589. RC := DosQueryPathInfo (FileRec (F).Name, ilStandard,
  590. @PathInfo, SizeOf (PathInfo));
  591. DosError := integer (RC);
  592. if RC = 0 then
  593. Attr := PathInfo.AttrFile;
  594. end;
  595. procedure SetFAttr (var F; Attr: word);
  596. var
  597. PathInfo: TFileStatus3;
  598. RC: cardinal;
  599. begin
  600. RC := DosQueryPathInfo (FileRec (F).Name, ilStandard,
  601. @PathInfo, SizeOf (PathInfo));
  602. if RC = 0 then
  603. begin
  604. PathInfo.AttrFile := Attr;
  605. RC := DosSetPathInfo (FileRec (F).Name, ilStandard, @PathInfo,
  606. SizeOf (PathInfo), doWriteThru);
  607. end;
  608. DosError := integer (RC);
  609. end;
  610. end.
  611. {
  612. $Log$
  613. Revision 1.32 2003-11-02 09:45:32 hajny
  614. SetFTime fix
  615. Revision 1.31 2003/11/01 18:35:12 hajny
  616. * GetFTime correction for case of no previous write access
  617. Revision 1.30 2003/10/25 23:55:22 hajny
  618. * Exec fix
  619. Revision 1.29 2003/10/25 22:45:37 hajny
  620. * file handling related fixes
  621. Revision 1.28 2003/10/05 22:06:43 hajny
  622. * result buffers must be allocated
  623. Revision 1.27 2003/10/03 21:46:41 peter
  624. * stdcall fixes
  625. Revision 1.26 2003/09/24 08:59:16 yuri
  626. * Prepared for native target (emx code replaced)
  627. Revision 1.25 2003/02/20 17:37:00 hajny
  628. * correction for previous mistyping
  629. Revision 1.24 2003/02/20 17:09:49 hajny
  630. * fixes for OS/2 v2.1 incompatibility
  631. Revision 1.23 2003/01/04 15:43:50 hajny
  632. + GetEnvPChar added
  633. Revision 1.22 2002/12/07 19:46:56 hajny
  634. * mistyping fixed
  635. Revision 1.21 2002/12/07 19:17:13 hajny
  636. * GetEnv correction, better PM support, ...
  637. Revision 1.20 2002/11/18 19:51:00 hajny
  638. * another bunch of type corrections
  639. Revision 1.19 2002/09/07 16:01:24 peter
  640. * old logs removed and tabs fixed
  641. Revision 1.18 2002/07/11 16:00:05 hajny
  642. * FindFirst fix (invalid attribute bits masked out)
  643. Revision 1.17 2002/07/07 18:00:48 hajny
  644. * DosGetInfoBlock modification to allow overloaded version (in DosCalls)
  645. Revision 1.16 2002/03/03 11:19:20 hajny
  646. * GetEnv rewritten to assembly - 3x faster now
  647. }