[fpc-pascal] DoDirSeparators and special filenames on Windows

Tomas Hajny XHajT03 at hajny.biz
Sun Sep 8 12:07:46 CEST 2013


On Sat, September 7, 2013 18:49, Bart wrote:
 .
 .
> 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).

Why do you believe that ExpandFilename is not threadsafe (on Windows or
any other platform)? If you refer to Sysutils.ExpandFilename, its
implementation is common and not specific for different platforms.
Obviously, there is special treatment implemented for specific
characteristics of path names and the set of these characteristics differs
among the supported platforms, but that should not make implementation for
one platform any special. The only platform specific part inside
ExpandFilename is a call to GetDir function retrieving the current
directory. If that is not 'threadsafe' by itself (on Windows), then your
statement is correct, but I hope that this is not the case. If you mean
that some other thread may change the current directory during execution
of ExpandFilename - well, that may be the case, but that is not special
for Windows and it should be the responsibility of the programmer either
not to change the current directory in other threads, or not to allow
relative paths (aka referring to a moving target). If you mean something
else, please elaborate.

Tomas





More information about the fpc-pascal mailing list