Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2013-09

ExtractFilePath and \ as pathdelim

3 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mattias Gaertner

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?  
 
Mattias
 

Michalis Kamburelis
to Mattias Gaertner
Mattias Gaertner wrote 7 lines
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

Reimar Grabowski
to Michalis Kamburelis
Show quoted text 5 lines
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.

+1

R.