[fpc-pascal] DoDirSeparators and special filenames on Windows

Bart bartjunk64 at gmail.com
Sun Sep 8 19:14:03 CEST 2013


On 9/8/13, Jürgen Hestermann <juergen.hestermann at gmx.de> wrote:

> It also says there that multithreaded applications should not use relative
> paths.
> It seems that WinAPI functions which allow relative paths suffer from the
> same problem:
> They have to call GetCurrentDirectory too and are therefore not thread-safe
> either.
> That means that you can use relative paths only for single-threaded
> programs.

Yes, it is a conundrum.
You cannot be threadsafe and use filenames that are not fully qualified.
And yet, I think many programs do, simply because the programmer did
not realize this (me included).

> So I see no harm in predending '\\?\' and expand relative paths if needed.

If needed, yes maybe, but if done silently it should then sanitize the
filename (change '/' into '\' , remove double PathDelims) for
backwards compatibiity, and the path should be expanded.
(It should, if apllied, probably be configurable @runtime.)

> Programmers who do not think/know about the special handling of long paths
> under Windows (maybe because they started with Linux) would still get a
> program that works with long paths too.

Hmm, long paths fail in Linux ATM (2.6.2) because all IO operations
use ShortStrings.

> I think this is expecially important because of the multi platform approach
> which IMO means that the programmer should *not* need to think about OS specialities
> (as far as possible).

Good point.

Another point is that (at least in Delphi mode) all this must remain
Delphi compatible.

Bart



More information about the fpc-pascal mailing list