4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
9 * Full author contact details are available in file CREDITS
17 #include <boost/utility.hpp>
23 * Path - utility closs for stackable working directories
25 * You can use a local variable of this type to temporarily
26 * change to a directory as the cwd, for example :
29 * Path p("/tmp/blah");
33 * At the end of p's scope the cwd is reset to its previous value.
35 class Path : boost::noncopyable {
37 /// change to the given directory
39 Path(string const & path)
43 pushedDir_ = getcwd();
44 if (pushedDir_.empty() || chdir(path))
51 /// set cwd to the previous value if needed
57 /// set cwd to the previous value if needed
60 /// whether we are in the new cwd or not
66 // To avoid the wrong usage:
67 // Path("/tmp"); // wrong
68 // Path p("/tmp"); // right
71 #define Path(x) unnamed_Path;
72 // Tip gotten from Bobby Schmidt's column in C/C++ Users Journal
74 } // namespace support