[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-users] platform neutral path concatenation



On Tue, Mar 07, 2006 at 01:50:59AM +1100, Item State wrote:
> is there some way to do platform neutral path
> concatenation such that
> 
> pathConcat( "dir", "file" )
> 
> returns "dir/file" on mac os and "dir\file" on
> windows? 
> 
> i've looked in String.sc and PathName.sc, only found
> ways to split paths.

not that i know of, but this would definitely be useful ...

> is there some way to clean determine the platform (mac
> os/ windows/ linux) in sclang without some tricky
> heuristics?

there are the platform directories (osx, windows, linux),
which should be used for this sort of stuff;
e.g. Process/Main could implement a method that is
overridden in a platform specific file:

+ Main {
    platform { ^\linux }
}

for Pathname we could follow a similar approach:

+ PathName {
    platformPathSeparator { ^$/ }
}

the handling of paths inside sclang could also be unified;
tcl for example converts all paths to unix conventions and
only converts them back when used externally. that way paths
can be split, concatenated etc. at will in the language.

i guess special care must be taken for windows X: style
drive ids.

> BTW why is scDir and path related stuff in string
> instead of path name?

good question ...

<sk>