Boost logo

Boost :

From: Lars Gullik Bjønnes (larsbj_at_[hidden])
Date: 2002-03-20 18:00:20

"Jeff Garland" <jeff_at_[hidden]> writes:

>> >int main()
>> >{
>> > std::string initial = getcwd();
>> >// rest unchanged
>> >}
>> There would be no difference at all at that point in the code. But if
>> initial_directory() is called again later by some library routine, it still
>> will give the correct answer. Eventually initial_directory() might become
>> part of the standard, and then would be set by the runtime library before
>> main() runs.
>> If anyone comes up with a killer argument for get/set cwd, we can include
>> them. But that hasn't happened so far.

Probably not a killer argument, but in LyX we call external programs
in a lot of cases as well as work with and handle files in a lot of
different directories. To be able to set the external programs cwd by
changing cwd inside LyX is nice, also to change the cwd inside lyx is
nice when working on several files in different dirs. We use a class
like this a lot of places:

class Path : boost::noncopyable {
        Path(string const & path)
                : popped_(false)
                if (!path.empty()) {
                        pushedDir_ = lyx::getcwd(); // GetCWD();
                } else {
                        popped_ = true;
                if (!popped_) pop();
        int pop();
        bool popped_;
        string pushedDir_;

If it is spawn, fork/exec or system does not really make a difference.


Boost list run by bdawes at, gregod at, cpdaniel at, john at