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
16 //#include "filetools.h"
18 #include <boost/utility.hpp>
26 * Path - utility closs for stackable working directories
28 * You can use a local variable of this type to temporarily
29 * change to a directory as the cwd, for example :
32 * Path p("/tmp/blah");
36 * At the end of p's scope the cwd is reset to its previous value.
38 class Path : boost::noncopyable {
40 /// change to the given directory
42 Path(string const & path)
46 pushedDir_ = lyx::getcwd();
47 if (pushedDir_.empty() || lyx::chdir(path))
54 /// set cwd to the previous value if needed
60 /// set cwd to the previous value if needed
63 /// whether we are in the new cwd or not
69 // To avoid the wrong usage:
70 // Path("/tmp"); // wrong
71 // Path p("/tmp"); // right
74 #define Path(x) unnamed_Path;
75 // Tip gotten from Bobby Schmidt's column in C/C++ Users Journal