Source Code (Use browser search to find items of interest.)

Class Index

klyx'PathStack (./klyx/src/pathstack.h:12)

class PathStack {
public:
	///
	PathStack() {
		Next = 0;
	}
	///
	PathStack(LString const & Path);
	///
	~PathStack();
	///
	int PathPush(LString const & Path);
	///
	int PathPop();
private:
	///
	LString Path;
	///
	PathStack *Next;
};

// global path stack

klyx'PathStack::PathStack() (./klyx/src/pathstack.C:29)

PathStack::PathStack(LString const & string)
	: Path(string)
{
	Next = NULL;
}

// Destructor

klyx'PathStack::~PathStack() (./klyx/src/pathstack.C:36)

PathStack::~PathStack()
{
	if (Next)
		delete Next;
}

// Changes to directory

klyx'PathStack::PathPush() (./klyx/src/pathstack.C:43)

int PathStack::PathPush(LString const & Path)
{
	// checks path string validity
	if (Path.empty()) return 1;

	PathStack *NewNode;

	// gets current directory and switch to new one
	LString CurrentPath = GetCWD();
	if ((CurrentPath.empty()) || chdir(Path.c_str())) {
		WriteFSAlert(i18n("Error: Could not change to directory: "), 
			     Path);
		return 2;
	}

	lyxerr.debug("PathPush: " + Path);
	// adds new node
	NewNode = new PathStack(CurrentPath);
	NewNode->Next = Next;
	Next = NewNode;
	return 0;
}

// Goes back to previous directory

klyx'PathStack::PathPop() (./klyx/src/pathstack.C:67)

int PathStack::PathPop()
{
	// checks stack validity and extracts old node
	PathStack *OldNode = Next;
	if (!OldNode) {
		WriteAlert (i18n("LyX Internal Error:"), i18n("Path Stack underflow."));
		return 1;
	}
	Next = OldNode->Next;
	OldNode->Next = NULL;

	// switches to old directory
	int Result = 0;
	if (chdir(OldNode->Path.c_str())) {
		WriteFSAlert(i18n("Error: Could not change to directory: "), 
			     Path);
		Result = 2;
	}
	lyxerr.debug("PathPop: " + OldNode->Path);
	delete OldNode;

	return Result;
}