[fpc-pascal] Paths on different OS's

Michael Preslar mike at lordlegacy.com
Thu Jul 14 19:45:10 CEST 2005


I always do something like this:

{$ifdef UNIX}
const dirsep = '/';
{$else}
const dirsep = '\';
{$endif}

path := ExtractFileDir(paramstr(0) + dirsep + 'somepath' + dirsep +
'directory' + 'etc' + dirsep);

Id imagine that one of fpc's units already has something very similar to
this.

-----Original Message-----
From: fpc-pascal-bounces at lists.freepascal.org
[mailto:fpc-pascal-bounces at lists.freepascal.org] On Behalf Of L505
Sent: Thursday, July 14, 2005 1:33 PM
To: FPC-Pascal users discussions
Subject: [fpc-pascal] Paths on different OS's


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/';

{$ifdef win32}
path:= ExtractFileDir(paramstr(0)+'\somepath\directory\etc\';

Thank you.

 


_______________________________________________
fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal





More information about the fpc-pascal mailing list