]> git.lyx.org Git - lyx.git/blobdiff - src/support/path.C
remove unused stuff
[lyx.git] / src / support / path.C
index 92388d9aedbd0b1e163ca5a66169980fbad6cb38..fd8f358f91460fb0391402c81ffe28b59129230c 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/filename.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(FileName(path))) {
+                       /* FIXME: throw */
+               }
+       } else {
+               popped_ = true;
+       }
+}
+
+
+Path::~Path()
+{
+       if (!popped_) pop();
+}
+
+
 int Path::pop()
 {
        if (popped_) {
@@ -23,7 +53,7 @@ int Path::pop()
                return 0;
        }
 
-       if (chdir(pushedDir_)) {
+       if (chdir(FileName(pushedDir_))) {
                // should throw an exception
                // throw DirChangeError();
        }