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 "filetools.h"
19 #include "lyx_gui_misc.h"
21 // $Id: pathstack.C,v 1.1 1999/09/27 18:44:38 larsbj Exp $
23 #if !defined(lint) && !defined(WITH_WARNINGS)
24 static char vcid[] = "$Id: pathstack.C,v 1.1 1999/09/27 18:44:38 larsbj Exp $";
28 PathStack lyxPathStack;
30 // Standard constructor
31 PathStack::PathStack(LString const & string)
38 PathStack::~PathStack()
44 // Changes to directory
45 int PathStack::PathPush(LString const & Path)
47 // checks path string validity
48 if (Path.empty()) return 1;
52 // gets current directory and switch to new one
53 LString CurrentPath = GetCWD();
54 if ((CurrentPath.empty()) || chdir(Path.c_str())) {
55 WriteFSAlert(_("Error: Could not change to directory: "),
60 lyxerr.debug("PathPush: " + Path);
62 NewNode = new PathStack(CurrentPath);
68 // Goes back to previous directory
69 int PathStack::PathPop()
71 // checks stack validity and extracts old node
72 PathStack *OldNode = Next;
74 WriteAlert (_("LyX Internal Error:"), _("Path Stack underflow."));
80 // switches to old directory
82 if (chdir(OldNode->Path.c_str())) {
83 WriteFSAlert(_("Error: Could not change to directory: "),
87 lyxerr.debug("PathPop: " + OldNode->Path);