]> git.lyx.org Git - lyx.git/blobdiff - src/support/path.C
* lyxfunctional.h: delete compare_memfun and helper classes
[lyx.git] / src / support / path.C
index 92388d9aedbd0b1e163ca5a66169980fbad6cb38..b3e46221d6d1682b7f59dc90ae5b2330833053b1 100644 (file)
 
 #include <config.h>
 
+// Needed to prevent the definition of the unnamed_Path macro in the header file.
+#define PATH_C
+
 #include "path.h"
+#include "lyxlib.h"
+
+
+using std::string;
+
 
 namespace lyx {
 namespace support {
 
+Path::Path(string const & path)
+       : popped_(false)
+{
+       if (!path.empty()) {
+               pushedDir_ = getcwd();
+               if (pushedDir_.empty() || chdir(path))
+                       /* FIXME: throw */;
+       } else {
+               popped_ = true;
+       }
+}
+
+
+Path::~Path()
+{
+       if (!popped_) pop();
+}
+
+
 int Path::pop()
 {
        if (popped_) {