[fpc-pascal] ExtractFilePath and \ as pathdelim
Michalis Kamburelis
michalis.kambi at gmail.com
Tue Sep 3 00:24:50 CEST 2013
Mattias Gaertner wrote:
> Hi all,
>
> ExtractFilePath and ExtractFileDir stops at last '/','\', so it treats the
> normal character \ as path delimiter under Unix.
>
> Is there a RTL function that handles the \ as normal character?
>
You can change global AllowDirectorySeparators
(http://www.freepascal.org/docs-html/rtl/system/allowdirectoryseparators.html
) to exclude '\' on non-Windows. I do this in my engine:
{$ifndef MSWINDOWS}
AllowDirectorySeparators -= ['\'];
{$endif}
This way ExtractFilePath and friends behave correctly on non-Windows.
And I really, really wish this would be changed in FPC too... That is,
AllowDirectorySeparators should be ['/'] on Unix, not ['/','\'].
Backslash is a completely normal character in Unix filenames. The
default value of AllowDirectorySeparators variable *should* be
OS-dependent, just like PathDelim and others.
Michalis
More information about the fpc-pascal
mailing list