[Lazarus] FileExistsUTF8 and long paths

Jürgen Hestermann juergen.hestermann at gmx.de
Fri Jan 15 18:49:48 CET 2016


With Lazarus RC2 (and I think before too) "FileExistsUTF8" uses
"_FileGetAttrUtf8" which again uses FileGetAttrWide (on Windows if Unicode is enable)
which again uses "Windows.GetFileAttributesW(PWideChar(UTF8Decode(FileName)))"

but this fails for long paths (if Length(FileName)>255).
Why not prepend "\\?\" at this last Windows step so it works for long paths too?


BTW:
I am not sure whether this leads to errors but while the result of the Windows API-function
GetFileAttributesW is declared to be DWORD
this result is converted (or is ist just typecasted?) to Integer in

function FileGetAttrWide(const FileName: String): Longint;
begin
Result:=Integer(Windows.GetFileAttributesW(PWideChar(UTF8Decode(FileName))));
end;

Doesn't this provoke at least a range check errors?
What happens when I compare the integer result with (DWORD) constants which havbe the first bit set?

This seems to be done at many places with many DWORD results from Windows API functions.
Is this a bug?




More information about the Lazarus mailing list