[fpc-pascal] Dos unit for Windows

Marco Borsari borsa77 at libero.it
Wed Jan 30 14:18:19 CET 2019


Hi all,
I have some problem with a file archiver which uses the Dos unit
under Windows, I suspect the flaw resides in GetFAttr function.
Looking in the source for Win RTL

procedure getfattr(var f;var attr : word);
var
   l : longint;
   s : RawByteString;
begin
  doserror:=0;
  s:=ToSingleByteFileSystemEncodedFileName(filerec(f).name);
  l:=GetFileAttributes(pchar(s));
  if l=longint($ffffffff) then
   begin
     doserror:=getlasterror;
     attr:=0;
   end
  else
   attr:=l and $ffff;
end;

I noted that two bytes are reported as a result, thought
IIRC in DOS only the low byte is affected while the high one
should be zero, so the assignment would become

   attr:=l and $ff;

Waiting for your comments,
Marco
-- 
Simplex sigillum veri



More information about the fpc-pascal mailing list