This commit was manufactured by cvs2svn to create tag
[lyx.git] / src / support / path.h
blobad5a905b4008aa0989d14c68835a515fad08de20
1 // -*- C++ -*-
2 #ifndef PATH_H
3 #define PATH_H
5 #include <unistd.h>
6 #include "LString.h"
7 #include "gettext.h"
8 #include "support/filetools.h"
9 #include "lyx_gui_misc.h"
11 class Path {
12 public:
13 ///
14 Path(string const & path)
15 : popped_(false)
17 if (!path.empty()) {
18 pushedDir_ = GetCWD();
19 if (pushedDir_.empty() || chdir(path.c_str())) {
20 WriteFSAlert(_("Error: Could not change to directory: "),
21 path);
23 } else {
24 popped_ = true;
27 ///
28 ~Path()
30 if (!popped_) pop();
32 ///
33 int pop()
35 if (popped_) {
36 WriteFSAlert(_("Error: Dir already popped: "),
37 pushedDir_);
38 return 0;
40 if (chdir(pushedDir_.c_str())) {
41 WriteFSAlert(
42 _("Error: Could not change to directory: "),
43 pushedDir_);
45 popped_ = true;
46 return 0;
48 private:
49 ///
50 bool popped_;
51 ///
52 string pushedDir_;
55 #endif