]> git.lyx.org Git - lyx.git/blobdiff - src/support/path.C
make "make distcheck" work
[lyx.git] / src / support / path.C
index 92388d9aedbd0b1e163ca5a66169980fbad6cb38..b7db0a299af77e212bb6d395b74ae8a0495d6cab 100644 (file)
 
 #include <config.h>
 
-#include "path.h"
+// Needed to prevent the definition of the unnamed_Path macro in the header file.
+#define PATH_C
+
+#include "support/path.h"
+#include "support/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_) {