]> git.lyx.org Git - lyx.git/blob - src/support/path.C
remove unused stuff
[lyx.git] / src / support / path.C
1 /**
2  * \file path.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Lars Gullik Bjønnes
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 // Needed to prevent the definition of the unnamed_Path macro in the header file.
14 #define PATH_C
15
16 #include "support/path.h"
17 #include "support/filename.h"
18 #include "support/lyxlib.h"
19
20
21 using std::string;
22
23
24 namespace lyx {
25 namespace support {
26
27 Path::Path(string const & path)
28         : popped_(false)
29 {
30         if (!path.empty()) {
31                 pushedDir_ = getcwd();
32
33                 if (pushedDir_.empty() || chdir(FileName(path))) {
34                         /* FIXME: throw */
35                 }
36         } else {
37                 popped_ = true;
38         }
39 }
40
41
42 Path::~Path()
43 {
44         if (!popped_) pop();
45 }
46
47
48 int Path::pop()
49 {
50         if (popped_) {
51                 // should throw an exception
52                 // throw logical_error();
53                 return 0;
54         }
55
56         if (chdir(FileName(pushedDir_))) {
57                 // should throw an exception
58                 // throw DirChangeError();
59         }
60         popped_ = true;
61
62         return 0;
63 }
64
65 } // namespace support
66 } // namespace lyx