dos.pas 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750
  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: PFileStatus3;
  165. begin
  166. New (FStat);
  167. DosError:=DosQueryFileInfo(FileRec(F).Handle, 1, FStat, SizeOf(FStat^));
  168. If DosError=0 then
  169. Time:=FStat^.timelastwrite+FStat^.DateLastWrite*256
  170. else
  171. Time:=0;
  172. Dispose (FStat);
  173. end;
  174. procedure SetFTime (var F; Time: longint);
  175. var FStat: PFileStatus3;
  176. RC: longint;
  177. begin
  178. New (FStat);
  179. RC := DosQueryFileInfo (FileRec (F).Handle, ilStandard, @FStat,
  180. SizeOf (FStat));
  181. if RC = 0 then
  182. begin
  183. FStat^.DateLastAccess := Hi (Time);
  184. FStat^.DateLastWrite := Hi (Time);
  185. FStat^.TimeLastAccess := Lo (Time);
  186. FStat^.TimeLastWrite := Lo (Time);
  187. RC := DosSetFileInfo (FileRec (F).Handle, ilStandard,
  188. FStat, SizeOf (FStat^));
  189. end;
  190. DosError := integer(RC);
  191. Dispose (FStat);
  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, Longint(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: longint;
  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: longint;
  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. const
  373. NameSize=255;
  374. var
  375. L, I: longint;
  376. type
  377. TRec = record
  378. T, D: word;
  379. end;
  380. begin
  381. with F do
  382. begin
  383. Name := FStat^.Name;
  384. Size := FStat^.FileSize;
  385. Attr := byte(FStat^.AttrFile and $FF);
  386. TRec (Time).T := FStat^.TimeLastWrite;
  387. TRec (Time).D := FStat^.DateLastWrite;
  388. end;
  389. end;
  390. procedure FindFirst (const Path: PathStr; Attr: word; var F: SearchRec);
  391. var path0: array[0..255] of char;
  392. Count: cardinal;
  393. begin
  394. {No error.}
  395. DosError := 0;
  396. New (F.FStat);
  397. F.Handle := longint ($FFFFFFFF);
  398. Count := 1;
  399. DosError := integer (DosFindFirst (Path, F.Handle,
  400. Attr and FindResvdMask, F.FStat, SizeOf (F.FStat^),
  401. Count, ilStandard));
  402. if (DosError = 0) and (Count = 0) then DosError := 18;
  403. DosSearchRec2SearchRec (F);
  404. end;
  405. procedure FindNext (var F: SearchRec);
  406. var
  407. Count: cardinal;
  408. begin
  409. {No error}
  410. DosError := 0;
  411. SearchRec2DosSearchRec (F);
  412. Count := 1;
  413. DosError := integer (DosFindNext (F.Handle, F.FStat, SizeOf (F.FStat^),
  414. Count));
  415. if (DosError = 0) and (Count = 0) then DosError := 18;
  416. DosSearchRec2SearchRec (F);
  417. end;
  418. procedure FindClose (var F: SearchRec);
  419. begin
  420. if F.Handle <> $FFFFFFFF then DosError := DosFindClose (F.Handle);
  421. Dispose (F.FStat);
  422. end;
  423. procedure swapvectors;
  424. {For TP compatibility, this exists.}
  425. begin
  426. end;
  427. function envcount:longint;
  428. begin
  429. envcount:=envc;
  430. end;
  431. function envstr(index : longint) : string;
  432. var hp:Pchar;
  433. begin
  434. if (index<=0) or (index>envcount) then
  435. begin
  436. envstr:='';
  437. exit;
  438. end;
  439. hp:=EnvP[index-1];
  440. envstr:=strpas(hp);
  441. end;
  442. function GetEnvPChar (EnvVar: string): PChar;
  443. (* The assembler version is more than three times as fast as Pascal. *)
  444. var
  445. P: PChar;
  446. begin
  447. EnvVar := UpCase (EnvVar);
  448. {$ASMMODE INTEL}
  449. asm
  450. cld
  451. mov edi, Environment
  452. lea esi, EnvVar
  453. xor eax, eax
  454. lodsb
  455. @NewVar:
  456. cmp byte ptr [edi], 0
  457. jz @Stop
  458. push eax { eax contains length of searched variable name }
  459. push esi { esi points to the beginning of the variable name }
  460. mov ecx, -1 { our character ('=' - see below) _must_ be found }
  461. mov edx, edi { pointer to beginning of variable name saved in edx }
  462. mov al, '=' { searching until '=' (end of variable name) }
  463. repne
  464. scasb { scan until '=' not found }
  465. neg ecx { what was the name length? }
  466. dec ecx { corrected }
  467. dec ecx { exclude the '=' character }
  468. pop esi { restore pointer to beginning of variable name }
  469. pop eax { restore length of searched variable name }
  470. push eax { and save both of them again for later use }
  471. push esi
  472. cmp ecx, eax { compare length of searched variable name with name }
  473. jnz @NotEqual { ... of currently found variable, jump if different }
  474. xchg edx, edi { pointer to current variable name restored in edi }
  475. repe
  476. cmpsb { compare till the end of variable name }
  477. xchg edx, edi { pointer to beginning of variable contents in edi }
  478. jz @Equal { finish if they're equal }
  479. @NotEqual:
  480. xor eax, eax { look for 00h }
  481. mov ecx, -1 { it _must_ be found }
  482. repne
  483. scasb { scan until found }
  484. pop esi { restore pointer to beginning of variable name }
  485. pop eax { restore length of searched variable name }
  486. jmp @NewVar { ... or continue with new variable otherwise }
  487. @Stop:
  488. xor eax, eax
  489. mov P, eax { Not found - return nil }
  490. jmp @End
  491. @Equal:
  492. pop esi { restore the stack position }
  493. pop eax
  494. mov P, edi { place pointer to variable contents in P }
  495. @End:
  496. end ['eax','ecx','edx','esi','edi'];
  497. GetEnvPChar := P;
  498. end;
  499. {$ASMMODE ATT}
  500. function GetEnv (const EnvVar: string): string;
  501. (* The assembler version is more than three times as fast as Pascal. *)
  502. begin
  503. GetEnv := StrPas (GetEnvPChar (EnvVar));
  504. end;
  505. procedure fsplit(path:pathstr;var dir:dirstr;var name:namestr;
  506. var ext:extstr);
  507. var p1,i : longint;
  508. dotpos : integer;
  509. begin
  510. { allow slash as backslash }
  511. for i:=1 to length(path) do
  512. if path[i]='/' then path[i]:='\';
  513. {Get drive name}
  514. p1:=pos(':',path);
  515. if p1>0 then
  516. begin
  517. dir:=path[1]+':';
  518. delete(path,1,p1);
  519. end
  520. else
  521. dir:='';
  522. { split the path and the name, there are no more path informtions }
  523. { if path contains no backslashes }
  524. while true do
  525. begin
  526. p1:=pos('\',path);
  527. if p1=0 then
  528. break;
  529. dir:=dir+copy(path,1,p1);
  530. delete(path,1,p1);
  531. end;
  532. { try to find out a extension }
  533. Ext:='';
  534. i:=Length(Path);
  535. DotPos:=256;
  536. While (i>0) Do
  537. Begin
  538. If (Path[i]='.') Then
  539. begin
  540. DotPos:=i;
  541. break;
  542. end;
  543. Dec(i);
  544. end;
  545. Ext:=Copy(Path,DotPos,255);
  546. Name:=Copy(Path,1,DotPos - 1);
  547. end;
  548. (*
  549. function FExpand (const Path: PathStr): PathStr;
  550. - declared in fexpand.inc
  551. *)
  552. {$DEFINE FPC_FEXPAND_UNC} (* UNC paths are supported *)
  553. {$DEFINE FPC_FEXPAND_DRIVES} (* Full paths begin with drive specification *)
  554. const
  555. LFNSupport = true;
  556. {$I fexpand.inc}
  557. {$UNDEF FPC_FEXPAND_DRIVES}
  558. {$UNDEF FPC_FEXPAND_UNC}
  559. procedure packtime(var d:datetime;var time:longint);
  560. var zs:longint;
  561. begin
  562. time:=-1980;
  563. time:=time+d.year and 127;
  564. time:=time shl 4;
  565. time:=time+d.month;
  566. time:=time shl 5;
  567. time:=time+d.day;
  568. time:=time shl 16;
  569. zs:=d.hour;
  570. zs:=zs shl 6;
  571. zs:=zs+d.min;
  572. zs:=zs shl 5;
  573. zs:=zs+d.sec div 2;
  574. time:=time+(zs and $ffff);
  575. end;
  576. procedure unpacktime (time:longint;var d:datetime);
  577. begin
  578. d.sec:=(time and 31) * 2;
  579. time:=time shr 5;
  580. d.min:=time and 63;
  581. time:=time shr 6;
  582. d.hour:=time and 31;
  583. time:=time shr 5;
  584. d.day:=time and 31;
  585. time:=time shr 5;
  586. d.month:=time and 15;
  587. time:=time shr 4;
  588. d.year:=time+1980;
  589. end;
  590. procedure getfattr(var f;var attr : word);
  591. var
  592. PathInfo: PFileStatus3;
  593. begin
  594. New (PathInfo);
  595. Attr:=0;
  596. DosError:=DosQueryPathInfo(FileRec(F).Name, ilStandard, PathInfo, SizeOf(PathInfo^));
  597. if DosError=0 then
  598. Attr := PathInfo^.attrFile;
  599. Dispose (PathInfo);
  600. end;
  601. procedure setfattr(var f;attr : word);
  602. var
  603. PathInfo: PFileStatus3;
  604. begin
  605. New (PathInfo);
  606. DosError:=DosQueryPathInfo(FileRec(F).Name, ilStandard, PathInfo, SizeOf(PathInfo^));
  607. if DosError=0 then
  608. begin
  609. PathInfo^.attrFile:=Attr;
  610. DosError:=DosSetPathInfo(FileRec(F).Name, ilStandard, PathInfo, SizeOf(PathInfo^), doWriteThru);
  611. end;
  612. Dispose (PathInfo);
  613. end;
  614. begin
  615. end.
  616. {
  617. $Log$
  618. Revision 1.28 2003-10-05 22:06:43 hajny
  619. * result buffers must be allocated
  620. Revision 1.27 2003/10/03 21:46:41 peter
  621. * stdcall fixes
  622. Revision 1.26 2003/09/24 08:59:16 yuri
  623. * Prepared for native target (emx code replaced)
  624. Revision 1.25 2003/02/20 17:37:00 hajny
  625. * correction for previous mistyping
  626. Revision 1.24 2003/02/20 17:09:49 hajny
  627. * fixes for OS/2 v2.1 incompatibility
  628. Revision 1.23 2003/01/04 15:43:50 hajny
  629. + GetEnvPChar added
  630. Revision 1.22 2002/12/07 19:46:56 hajny
  631. * mistyping fixed
  632. Revision 1.21 2002/12/07 19:17:13 hajny
  633. * GetEnv correction, better PM support, ...
  634. Revision 1.20 2002/11/18 19:51:00 hajny
  635. * another bunch of type corrections
  636. Revision 1.19 2002/09/07 16:01:24 peter
  637. * old logs removed and tabs fixed
  638. Revision 1.18 2002/07/11 16:00:05 hajny
  639. * FindFirst fix (invalid attribute bits masked out)
  640. Revision 1.17 2002/07/07 18:00:48 hajny
  641. * DosGetInfoBlock modification to allow overloaded version (in DosCalls)
  642. Revision 1.16 2002/03/03 11:19:20 hajny
  643. * GetEnv rewritten to assembly - 3x faster now
  644. }