[fpc-pascal] DoDirSeparators and special filenames on Windows
Bart
bartjunk64 at gmail.com
Sat Sep 7 18:49:20 CEST 2013
On 9/7/13, Jürgen Hestermann <juergen.hestermann at gmx.de> wrote:
> Am 2013-09-07 12:52, schrieb Bart:
>
> > Note that '//?/C:/foo/bar' in contrast happily opens 'C:\foo\bar'
> > (nice touch from M$).
>
> Why is this a "nice touch"? IMO it is crap.
You missed the intended sarcasme sign. ;-)
>
> In general I would prefer if this '\\?\' prefix is hidden away from the
> programmer at all. File names should be just that: File names. On windows
> *every* API function that expects file names should be prepended with '\\?\'
> internally
That would be wrong.
Prepending wiht '\\?\ means that everything should be taken literally,
so trying to open/read etc. through WinApi will fail if filename
contains double pathedlims, dots, '/' etc, because these are illegal
characters in a filename on Windows.
This is especially a problem with Lazarus (the IDE itself), where
config files and include directives may contain '/', or are defined as
relative paths.
You would also not be able to open files with a relative path:
FileExists('foo\bar.txt') wil then internally be translated to "Ask
the WinApi if '\\?\foo\bar.txt' exists", and this will fail, since the
'\\?\' scheme needs a fully qualified path.
(And in a threaded program you may not want to call ExpandFilename(),
since on Windows this is not threadsafe).
Bart
More information about the fpc-pascal
mailing list