[fpc-pascal] Paths on different OS's

Michael Van Canneyt michael at freepascal.org
Thu Jul 14 15:39:19 CEST 2005



On Thu, 14 Jul 2005, L505 wrote:

> Could someone tell me the way forward and backward slashes are handled easily?
> 
> For example this is sort of code bloat below
> Is there some way around this:
> 
> {$ifdef unix}
> path:= ExtractFileDir(paramstr(0)+'/somepath/directory/etc/';

Path:=ExtractFileDir(ParamStr(0)+PathDelim+'SomePath'+PatHDelim+'Directory'+PatHDelim+'etc'+PathDelim;

Is cross platform, or

Path:=ExtractFileDir(SetDirSeparators(paramstr(0)+'\somepath\directory\etc\'));

DoDirSeparators is the same as SetDirSeparators, but operates on a var param.

All these functions are in sysutils, and are documented.

Michael.




More information about the fpc-pascal mailing list