[Lazarus] FileExistsUTF8 and long paths

Jürgen Hestermann juergen.hestermann at gmx.de
Sat Jan 16 14:01:59 CET 2016


Am 2016-01-16 um 00:11 schrieb Bart:
 > On 1/15/16, Jürgen Hestermann <juergen.hestermann at gmx.de> wrote:
 >> Why not prepend "\\?\" at this last Windows step so it works for long paths
 > This will break existing programs, including the ide.
 > Currently you can use both / and \ in filenames on Wndows filename
 > functions, because the API does not care.
 > That is unlues you prepend \\?\, then character in the given string
 > MUST be in the filename.
 > Also this will then return false on '..\foo.bar', sincenow te APi
 > expects that the two dots are part of the filename.

Well, at least when the path is too long (length(FileName>MAXPATH))
it can prepend \\?\ because it will fail without it anyway.

I have found this issue the hard way as I checked for file existence in
my program and it reported false although the file existed.
So I overwrote it. IMO this is a bug.
A function that claims to check for file existence should be as reliable
as possible and not have some obscure side effects.


 > See the comments in ExpandFilenameUTF8 (I think I put a reference there).

I did not find any comments that mentions long paths




More information about the Lazarus mailing list