4 * Copyright 1995-2002 the LyX Team
5 * Read the file COPYING
14 //#include "filetools.h"
16 #include <boost/utility.hpp>
24 * Path - utility closs for stackable working directories
26 * You can use a local variable of this type to temporarily
27 * change to a directory as the cwd, for example :
30 * Path p("/tmp/blah");
34 * At the end of p's scope the cwd is reset to its previous value.
36 class Path : boost::noncopyable {
38 /// change to the given directory
40 Path(string const & path)
44 pushedDir_ = lyx::getcwd();
45 if (pushedDir_.empty() || lyx::chdir(path))
52 /// set cwd to the previous value if needed
58 /// set cwd to the previous value if needed
61 /// whether we are in the new cwd or not
67 // To avoid the wrong usage:
68 // Path("/tmp"); // wrong
69 // Path p("/tmp"); // right
72 #define Path(x) unnamed_Path;
73 // Tip gotten from Bobby Schmidt's column in C/C++ Users Journal