Boost logo

Boost :

From: Dylan Nicholson (dylan_nicholson_at_[hidden])
Date: 2002-04-08 22:17:44


 --- Jeff Garland <jeff_at_[hidden]> wrote: > Seems like there are
a few non-portable LOC in your program:
>
>
> if ( find_file( boost_root_dir + dir_sep() + "status" + dir_sep() +
> "config_info.test",
>
> So on Windows dir_sep() would be "\" and on Unix it would be "/". Or is
> something in the core going
> to convert "/" to the right thing?
>
I think that's preferable actually especially because under Windows the
conversion is unnecessary. Given that '/' works under the vast majority of
commonly used operating systems that people are likely to be writing C++ code
for, and that it is vastly easier to read than using things like dir_sep or
compose, it would be my choice.
Of course a function may be required to produce a string in a particular OS's
format for passing to fstream/filebuf etc., which can be used at the
developer's discretion depending on how portable they want their code to be:

// we only support platforms that can understand '/'
std::ofstream ofs((some_directory() + "/data/datafile.txt").c_str());

// we might support some that don't:
std::ofstream ofs((boost::filesystem::os_pathname(some_directory() +
"/data/datafile.txt")).c_str());

Dylan

http://www.sold.com.au - SOLD.com.au Auctions
- 1,000s of Bargains!


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk