[Lazarus] FileExistsUTF8 and long paths

Jürgen Hestermann juergen.hestermann at gmx.de
Sun Jan 17 17:32:18 CET 2016


Am 2016-01-17 um 15:39 schrieb Bart:
 >>  > AFACS it cannot be resolved/fixed in a manner that will not break
 >>  > backwards compatibility.
 >> I think it is possible (see above).
 >> You only need to find out the exact limitations and detect them before
 >> adding \\?\
 > Only if we decide to _always_ try that (under specified circumstances).
 > If not it will be an optional parameter and the function then will
 > have a different signature, which will be incompatible with existing
 > programs using it as a function variable.

If you check for \\?\ (which is already done),
detect (or even expand) relative paths and
detect slashes (or even convert them to backslashes)
then no backward compatibility would be broken.
No drawback but the advantage of no failure for long paths.


 >>> Further more: this is not something that belongs to Lazarus, but to fpc.
 >> I am not sure. I thought FileExistsUTF8 is part of Lazarus, not Free Pascal.
 > The only difference between File* and File*UTF8 functions
 > (fpc<->Lazarus) is that the UTF8 versions were/are able to handle any
 > unicodecharacter inside the given path/filename (regardless of you
 > current Windows codepage).
 > Otherwise it does not behave different compared to the fpc File*
 > functions, nor should it.

Still the original function I mentioned was from Lazarus.
Therefore I wrote this to the Lazarus forum.
Otherwise I would have been blamed for not using the right forum. ;-)


BTW:
The following code in ExpandFileNameUtf8 seems to be not quite correct:

  if (Length(Fn) > 3) and (Fn[1] = PathDelim) and (Fn[2] = PathDelim) and
      (Fn[3] = '?') and (Fn[4] = PathDelim) //Do NOT use AllowDirectorySeparators here!
     then Exit;

When PathDelim='/' it would make no sense.
Only Windows has the '\\?\' prefix and as far as I know it cannot be '//?/'.
For Linux this maybe a valid file/directory name (but I don't know).





More information about the Lazarus mailing list