]> git.lyx.org Git - lyx.git/blobdiff - src/support/path.h
* src/text2.C: deleteEmptyParagraphMechanism(): fix a crash in
[lyx.git] / src / support / path.h
index 4b802cc14c947463bdd79536d5d38e5271d2dc32..13296353aa6a87ce6b919773e6c2804915cb1663 100644 (file)
@@ -1,24 +1,25 @@
 // -*- C++ -*-
 /**
  * \file path.h
- * Copyright 1995-2002 the LyX Team
- * Read the file COPYING
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- * \author unknown
+ * \author Lars Gullik Bjønnes
+ *
+ * Full author contact details are available in file CREDITS.
  */
 
 #ifndef PATH_H
 #define PATH_H
 
-#include "LString.h"
-//#include "filetools.h"
-#include "lyxlib.h"
+#include "support/filename.h"
+
 #include <boost/utility.hpp>
 
-#ifdef __GNUG__
-#pragma interface
-#endif
+#include <string>
 
+namespace lyx {
+namespace support {
 
 /**
  * Path - utility closs for stackable working directories
@@ -28,7 +29,7 @@
  *
  * if (blah) {
  *     Path p("/tmp/blah");
- *     ...
+ *     ...
  * }
  *
  * At the end of p's scope the cwd is reset to its previous value.
 class Path : boost::noncopyable {
 public:
        /// change to the given directory
-       explicit
-       Path(string const & path)
-               : popped_(false)
-       {
-               if (!path.empty()) { 
-                       pushedDir_ = lyx::getcwd();
-                       if (pushedDir_.empty() || lyx::chdir(path))
-                               /* FIXME: throw */;
-               } else {
-                       popped_ = true;
-               }
-       }
+       explicit Path(std::string const & path);
+
        /// set cwd to the previous value if needed
-       ~Path()
-       {
-               if (!popped_) pop();
-       }
+       ~Path();
+
        /// set cwd to the previous value if needed
        int pop();
 private:
        /// whether we are in the new cwd or not
        bool popped_;
        /// the previous cwd
-       string pushedDir_;
+       FileName pushedDir_;
 };
 
 // To avoid the wrong usage:
@@ -69,7 +56,13 @@ private:
 // Path p("/tmp");  // right
 // we add this macro:
 ///
-#define Path(x) unnamed_Path;
+// With boost 1.34 this is not usable anymore
+//#ifndef PATH_C
+//#define Path(x) unnamed_Path;
+//#endif
 // Tip gotten from Bobby Schmidt's column in C/C++ Users Journal
 
+} // namespace support
+} // namespace lyx
+
 #endif // PATH_H