1 // lyx-stack.C : implementation of PathStack class
2 // this file is part of LyX, the High Level Word Processor
3 // copyright (C) 1995-1996, Matthias Ettrich and the LyX Team
9 #pragma implementation "pathstack.h"
12 #include "pathstack.h"
13 #include "support/filetools.h"
19 #include "lyx_gui_misc.h"
22 PathStack lyxPathStack;
24 // Standard constructor
25 PathStack::PathStack(string const & string)
32 PathStack::~PathStack()
38 // Changes to directory
39 int PathStack::PathPush(string const & Path)
41 // checks path string validity
42 if (Path.empty()) return 1;
46 // gets current directory and switch to new one
47 string CurrentPath = GetCWD();
48 if ((CurrentPath.empty()) || chdir(Path.c_str())) {
49 WriteFSAlert(_("Error: Could not change to directory: "),
54 lyxerr.debug() << "PathPush: " << Path << endl;
56 NewNode = new PathStack(CurrentPath);
62 // Goes back to previous directory
63 int PathStack::PathPop()
65 // checks stack validity and extracts old node
66 PathStack *OldNode = Next;
68 WriteAlert (_("LyX Internal Error:"), _("Path Stack underflow."));
74 // switches to old directory
76 if (chdir(OldNode->Path.c_str())) {
77 WriteFSAlert(_("Error: Could not change to directory: "),
81 lyxerr.debug() << "PathPop: " << OldNode->Path << endl;