Re: [Lazarus] FileExistsUTF8 and long paths

2016-01-19 Thread Bart
On 1/19/16, Jürgen Hestermann wrote: > > If I understood you correctly you would want to have > > function FileXXXUtf8(Fn) do: > > begin > > if (Length(Fn) > MaxPath) and (not StartsWith('\\?\',Fn) then > > FileXXXUtf8('\\?\' + Fn) > > else > >

Re: [Lazarus] FileExistsUTF8 and long paths

2016-01-19 Thread Jürgen Hestermann
Am 2016-01-17 um 18:12 schrieb Bart: > On 1/17/16, Jürgen Hestermann wrote: >> 2. without forward slashes and > But then the function would not act on \\?\C:\maxpathchars\foo/bar if > you omitted the \\?\, which seems to be the intention of your > proposal? I don't

Re: [Lazarus] FileExistsUTF8 and long paths

2016-01-17 Thread Jürgen Hestermann
Am 2016-01-17 um 12:42 schrieb Bart: > On 1/16/16, Jürgen Hestermann wrote: >> Well, at least when the path is too long (length(FileName>MAXPATH)) >> it can prepend \\?\ because it will fail without it anyway. > That won't do for the same reasons as explained above. >

Re: [Lazarus] FileExistsUTF8 and long paths

2016-01-17 Thread Jürgen Hestermann
Am 2016-01-17 um 14:23 schrieb Jürgen Hestermann: > Additional checks (i.e. for dots) are needed > but I think it should be possible to find out > when a path is: > 1. not relative and > 2. without forward slashes and > 3. too long to be resolved without prepended \\?\ Even better would be to do

Re: [Lazarus] FileExistsUTF8 and long paths

2016-01-17 Thread Sven Barth
Am 17.01.2016 14:23 schrieb "Jürgen Hestermann" : > >> I did not find any comments that mentions long paths > > You need new glasses then ;-) > > === code == > > //if Filename uses ExtendedLengthPath scheme then it cannot be expanded > > //AND it should not be

Re: [Lazarus] FileExistsUTF8 and long paths

2016-01-17 Thread Sven Barth
Am 17.01.2016 12:42 schrieb "Bart" : > In the end I used a bootable linux dvd (puppy linux), mounted the > partition in question and used the filemanger from that distro to > remove the folder and file. You know that you could just have written a program that uses the *W API

Re: [Lazarus] FileExistsUTF8 and long paths

2016-01-17 Thread Bart
On 1/16/16, Jürgen Hestermann wrote: > Well, at least when the path is too long (length(FileName>MAXPATH)) > it can prepend \\?\ because it will fail without it anyway. That won't do for the same reasons as explained above. Say you have a directory:

Re: [Lazarus] FileExistsUTF8 and long paths

2016-01-17 Thread Bart
On 1/17/16, Sven Barth wrote: > > You know that you could just have written a program that uses the *W API to > delete files with a \\?\ prefixed path? ;) I did that, and id did not work. Probably because I did something wrong. To be honest, I then removed the file

Re: [Lazarus] FileExistsUTF8 and long paths

2016-01-17 Thread Bart
On 1/17/16, Jürgen Hestermann wrote: > > 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 \\?\

Re: [Lazarus] FileExistsUTF8 and long paths

2016-01-17 Thread Bart
On 1/17/16, Jürgen Hestermann wrote: > >> I did not find any comments that mentions long paths > > You need new glasses then ;-) > > === code == > > //if Filename uses ExtendedLengthPath scheme then it cannot be expanded > > //AND it should not be altered by

Re: [Lazarus] FileExistsUTF8 and long paths

2016-01-17 Thread Jürgen Hestermann
Am 2016-01-17 um 15:25 schrieb Bart: > Quoted from the link: > "To specify an extended-length path, use the "\\?\" prefix. For > example, "\\?\D:\very long path"." > Maybe you need new eyes, not new glasses ;-) I know the Windows API specification very well. But you seem to forget the original

Re: [Lazarus] FileExistsUTF8 and long paths

2016-01-17 Thread Bart
On 1/17/16, Jürgen Hestermann wrote: > How does the comment bring any new facts to the discussion? > It just repeats the text you wrote before. > I expected more information in the comment which I did not find. We seem to misunderstand eachther, or at least I do so.

Re: [Lazarus] FileExistsUTF8 and long paths

2016-01-17 Thread Jürgen Hestermann
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

Re: [Lazarus] FileExistsUTF8 and long paths

2016-01-17 Thread Bart
On 1/17/16, Jürgen Hestermann wrote: > 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 >

Re: [Lazarus] FileExistsUTF8 and long paths

2016-01-17 Thread Bart
On 1/17/16, Bart wrote: > include direcory Read: "include directive" Bart -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Re: [Lazarus] FileExistsUTF8 and long paths

2016-01-17 Thread Bart
On 1/17/16, Jürgen Hestermann wrote: > Yes, that's true. > Additional checks (i.e. for dots) are needed > but I think it should be possible to find out > when a path is: > > 1. not relative and Yes. > 2. without forward slashes and But then the function would not

Re: [Lazarus] FileExistsUTF8 and long paths

2016-01-16 Thread Jürgen Hestermann
Am 2016-01-16 um 00:11 schrieb Bart: > On 1/15/16, Jürgen Hestermann 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

Re: [Lazarus] FileExistsUTF8 and long paths

2016-01-16 Thread Ondrej Pokorny
On 16.01.2016 14:01, Jürgen Hestermann wrote: 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

[Lazarus] FileExistsUTF8 and long paths

2016-01-15 Thread Jürgen Hestermann
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

Re: [Lazarus] FileExistsUTF8 and long paths

2016-01-15 Thread Bart
On 1/15/16, Jürgen Hestermann 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