Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-03-21 06:16:05


From: "Beman Dawes" <bdawes_at_[hidden]>
> >How is this superior to simply providing a getcwd() function and letting
> >the user do
> >
> >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.

+ getcwd:

I call a library routine

std::string get_some_file_path();

It returns without an error. The path is valid. I can open the file using
std::fopen. All is well. Now I want to store that path somewhere so I can
access it again when my application is restarted. I can't do that. The path
may be relative, and there is no guarantee that it will refer to the same
file next time I fopen() it.

+ setcwd:

I need to interoperate with a piece of code (library, executable) that is
affected by the current directory.


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