I am not really planning for any of this to go in now, but I wanted to
play a bit with boost::filesystem to see how it fit... Not too badly
it turns out, but the restrictions on filenames might be tough.

Anyhow this is the patch... we can actually remove some code if we go
down this road later.

? fs.diff
? boost/boost/filesystem
? boost/libs/filesystem
Index: configure.ac
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/configure.ac,v
retrieving revision 1.13
diff -u -p -r1.13 configure.ac
--- configure.ac	21 Sep 2003 16:02:51 -0000	1.13
+++ configure.ac	6 Oct 2003 01:05:45 -0000
@@ -402,6 +402,8 @@ AC_CONFIG_SUBDIRS(lib lib/reLyX)
 AC_CONFIG_FILES([Makefile \
        boost/Makefile \
        boost/libs/Makefile \
+       boost/libs/filesystem/Makefile \
+       boost/libs/filesystem/src/Makefile \
        boost/libs/regex/Makefile \
        boost/libs/regex/src/Makefile \
        boost/libs/signals/Makefile \
Index: boost/libs/Makefile.am
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/boost/libs/Makefile.am,v
retrieving revision 1.3
diff -u -p -r1.3 Makefile.am
--- boost/libs/Makefile.am	26 May 2002 13:02:16 -0000	1.3
+++ boost/libs/Makefile.am	6 Oct 2003 01:05:46 -0000
@@ -1,3 +1,3 @@
 include $(top_srcdir)/config/common.am
 
-SUBDIRS = regex signals
+SUBDIRS = filesystem regex signals
Index: src/BufferView_pimpl.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v
retrieving revision 1.439
diff -u -p -r1.439 BufferView_pimpl.C
--- src/BufferView_pimpl.C	21 Sep 2003 23:00:41 -0000	1.439
+++ src/BufferView_pimpl.C	6 Oct 2003 01:05:46 -0000
@@ -81,7 +81,6 @@ using bv_funcs::underline;
 
 using lyx::pos_type;
 
-using lyx::support::AddPath;
 using lyx::support::bformat;
 using lyx::support::FileSearch;
 using lyx::support::IsDirWriteable;
@@ -899,7 +898,7 @@ void BufferView::Pimpl::MenuInsertLyXFil
 			make_pair(string(_("Documents|#o#O")),
 				  string(lyxrc.document_path)),
 			make_pair(string(_("Examples|#E#e")),
-				  string(AddPath(system_lyxdir(), "examples"))));
+				  (system_lyxdir() / "examples").string()));
 
 		FileDialog::Result result =
 			fileDlg.open(initpath,
Index: src/Makefile.am
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/Makefile.am,v
retrieving revision 1.192
diff -u -p -r1.192 Makefile.am
--- src/Makefile.am	17 Sep 2003 16:44:51 -0000	1.192
+++ src/Makefile.am	6 Oct 2003 01:05:47 -0000
@@ -21,7 +21,8 @@ LYX_POST_LIBS = frontends/controllers/li
 	support/libsupport.la
 
 if USE_INCLUDED_BOOST
-BOOST_LIBS = ../boost/libs/regex/src/libboostregex.la \
+BOOST_LIBS = ../boost/libs/filesystem/src/libboostfilesystem.la \
+	../boost/libs/regex/src/libboostregex.la \
 	../boost/libs/signals/src/libboostsignals.la
 else
 BOOST_LIBS = -lboost_regex -lboost_signals
Index: src/lyx_cb.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyx_cb.C,v
retrieving revision 1.226
diff -u -p -r1.226 lyx_cb.C
--- src/lyx_cb.C	16 Sep 2003 11:03:17 -0000	1.226
+++ src/lyx_cb.C	6 Oct 2003 01:05:47 -0000
@@ -122,7 +122,7 @@ bool WriteAs(Buffer * buffer, string con
 			make_pair(string(_("Documents|#o#O")),
 				  string(lyxrc.document_path)),
 			make_pair(string(_("Templates|#T#t")),
-				  string(lyxrc.template_path)));
+				  lyxrc.template_path.string()));
 
 		if (!IsLyXFilename(fname))
 			fname += ".lyx";
@@ -184,7 +184,7 @@ void QuitLyX()
 		if (!bufferlist.quitWriteAll())
 			return;
 
-		lastfiles->writeFile(lyxrc.lastfiles);
+		lastfiles->writeFile(lyxrc.lastfiles.string());
 	}
 
 	// Set a flag that we do quitting from the program,
@@ -478,7 +478,7 @@ void Reconfigure(BufferView * bv)
 	Path p(user_lyxdir());
 	Systemcall one;
 	one.startscript(Systemcall::Wait,
-			AddName(system_lyxdir(), "configure"));
+			(system_lyxdir() / "configure").string());
 	p.pop();
 	bv->owner()->message(_("Reloading configuration..."));
 	lyxrc.read(LibFileSearch(string(), "lyxrc.defaults"));
Index: src/lyx_main.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyx_main.C,v
retrieving revision 1.177
diff -u -p -r1.177 lyx_main.C
--- src/lyx_main.C	26 Sep 2003 14:27:19 -0000	1.177
+++ src/lyx_main.C	6 Oct 2003 01:05:47 -0000
@@ -49,12 +49,12 @@
 #include "support/path_defines.h"
 
 #include <boost/bind.hpp>
+#include <boost/filesystem/operations.hpp>
 
 #include <iostream>
 #include <csignal>
 
 using lyx::support::AddName;
-using lyx::support::AddPath;
 using lyx::support::bformat;
 using lyx::support::createDirectory;
 using lyx::support::CreateLyXTmpDir;
@@ -71,6 +71,7 @@ using lyx::support::system_lyxdir;
 using lyx::support::user_lyxdir;
 
 namespace os = lyx::support::os;
+namespace fs = boost::filesystem;
 
 using std::endl;
 
@@ -265,11 +266,11 @@ void LyX::init(bool gui)
 	lyx_gui::use_gui = gui;
 
 	if (lyxrc.template_path.empty()) {
-		lyxrc.template_path = AddPath(system_lyxdir(), "templates");
+		lyxrc.template_path = system_lyxdir() / "templates";
 	}
 
 	if (lyxrc.lastfiles.empty()) {
-		lyxrc.lastfiles = AddName(user_lyxdir(), "lastfiles");
+		lyxrc.lastfiles = user_lyxdir() / "lastfiles";
 	}
 
 	if (lyxrc.roman_font_name.empty())
@@ -322,8 +323,8 @@ void LyX::init(bool gui)
 	}
 
 	lyxerr[Debug::INIT] << "Reading lastfiles `"
-			    << lyxrc.lastfiles << "'..." << endl;
-	lastfiles.reset(new LastFiles(lyxrc.lastfiles,
+			    << lyxrc.lastfiles.string() << "'..." << endl;
+	lastfiles.reset(new LastFiles(lyxrc.lastfiles.string(),
 				      lyxrc.check_lastfiles,
 				      lyxrc.num_lastfiles));
 }
@@ -428,20 +429,20 @@ void LyX::deadKeyBindings(kb_keymap * kb
 
 void LyX::queryUserLyXDir(bool explicit_userdir)
 {
-	string const configure_script = AddName(system_lyxdir(), "configure");
+	fs::path const configure_script = system_lyxdir() / "configure";
 
 	// Does user directory exist?
 	FileInfo fileInfo(user_lyxdir());
 	if (fileInfo.isOK() && fileInfo.isDir()) {
 		first_start = false;
 		FileInfo script(configure_script);
-		FileInfo defaults(AddName(user_lyxdir(), "lyxrc.defaults"));
+		FileInfo defaults(user_lyxdir() / "lyxrc.defaults");
 		if (defaults.isOK() && script.isOK()
 		    && defaults.getModificationTime() < script.getModificationTime()) {
 			lyxerr << _("LyX: reconfiguring user directory")
 			       << endl;
 			Path p(user_lyxdir());
-			::system(configure_script.c_str());
+			::system(configure_script.string().c_str());
 			lyxerr << "LyX: " << _("Done!") << endl;
 		}
 		return;
@@ -450,19 +451,23 @@ void LyX::queryUserLyXDir(bool explicit_
 	first_start = !explicit_userdir;
 
 	lyxerr << bformat(_("LyX: Creating directory %1$s"
-				  " and running configure..."), user_lyxdir()) << endl;
+			    " and running configure..."),
+			  user_lyxdir().string()) << endl;
 
-	if (!createDirectory(user_lyxdir(), 0755)) {
+	if (!fs::exists(user_lyxdir()))
+	    fs::create_directory(user_lyxdir());
+
+	if (!fs::is_directory(user_lyxdir())) {
 		// Failed, let's use $HOME instead.
 		user_lyxdir(GetEnvPath("HOME"));
 		lyxerr << bformat(_("Failed. Will use %1$s instead."),
-			user_lyxdir()) << endl;
+			user_lyxdir().string()) << endl;
 		return;
 	}
 
 	// Run configure in user lyx directory
 	Path p(user_lyxdir());
-	::system(configure_script.c_str());
+	::system(configure_script.string().c_str());
 	lyxerr << "LyX: " << _("Done!") << endl;
 }
 
Index: src/lyxfunc.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxfunc.C,v
retrieving revision 1.507
diff -u -p -r1.507 lyxfunc.C
--- src/lyxfunc.C	2 Oct 2003 14:42:31 -0000	1.507
+++ src/lyxfunc.C	6 Oct 2003 01:05:48 -0000
@@ -83,7 +83,6 @@ using bv_funcs::INC_DEPTH;
 using bv_funcs::update_and_apply_freefont;
 
 using lyx::support::AddName;
-using lyx::support::AddPath;
 using lyx::support::bformat;
 using lyx::support::ChangeExtension;
 using lyx::support::FileInfo;
@@ -1766,10 +1765,10 @@ void LyXFunc::menuNew(string const & nam
 			make_pair(string(_("Documents|#o#O")),
 				  string(lyxrc.document_path)),
 			make_pair(string(_("Templates|#T#t")),
-				  string(lyxrc.template_path)));
+				  lyxrc.template_path.string()));
 
 		FileDialog::Result result =
-			fileDlg.open(lyxrc.template_path,
+			fileDlg.open(lyxrc.template_path.string(),
 				       _("*.lyx| LyX Documents (*.lyx)"));
 
 		if (result.first == FileDialog::Later)
@@ -1805,7 +1804,7 @@ void LyXFunc::open(string const & fname)
 			make_pair(string(_("Documents|#o#O")),
 				  string(lyxrc.document_path)),
 			make_pair(string(_("Examples|#E#e")),
-				  string(AddPath(system_lyxdir(), "examples"))));
+				  (system_lyxdir() / "examples").string()));
 
 		FileDialog::Result result =
 			fileDlg.open(initpath,
@@ -1880,7 +1879,7 @@ void LyXFunc::doImport(string const & ar
 			make_pair(string(_("Documents|#o#O")),
 				  string(lyxrc.document_path)),
 			make_pair(string(_("Examples|#E#e")),
-				  string(AddPath(system_lyxdir(), "examples"))));
+				  (system_lyxdir() / "examples").string()));
 
 		string const extension = "*." + formats.extension(format)
 			+ "| " + formats.prettyName(format)
Index: src/lyxrc.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxrc.C,v
retrieving revision 1.159
diff -u -p -r1.159 lyxrc.C
--- src/lyxrc.C	16 Sep 2003 09:01:10 -0000	1.159
+++ src/lyxrc.C	6 Oct 2003 01:05:48 -0000
@@ -1506,8 +1506,8 @@ void LyXRC::output(ostream & os) const
 			os << "\\document_path \"" << document_path << "\"\n";
 		}
 	case RC_LASTFILES:
-		if (lastfiles != system_lyxrc.lastfiles) {
-			os << "\\lastfiles \"" << lastfiles << "\"\n";
+		if (lastfiles.string() != system_lyxrc.lastfiles.string()) {
+			os << "\\lastfiles \"" << lastfiles.string() << "\"\n";
 		}
 	case RC_NUMLASTFILES:
 		if (num_lastfiles != system_lyxrc.num_lastfiles) {
@@ -1519,8 +1519,8 @@ void LyXRC::output(ostream & os) const
 			   << '\n';
 		}
 	case RC_TEMPLATEPATH:
-		if (template_path != system_lyxrc.template_path) {
-			os << "\\template_path \"" << template_path << "\"\n";
+		if (template_path.string() != system_lyxrc.template_path.string()) {
+			os << "\\template_path \"" << template_path.string() << "\"\n";
 		}
 	case RC_TEMPDIRPATH:
 		if (tempdir_path != system_lyxrc.tempdir_path) {
Index: src/lyxrc.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxrc.h,v
retrieving revision 1.79
diff -u -p -r1.79 lyxrc.h
--- src/lyxrc.h	15 Sep 2003 02:24:31 -0000	1.79
+++ src/lyxrc.h	6 Oct 2003 01:05:48 -0000
@@ -21,6 +21,8 @@
 #include "paper.h"
 #include "graphics/GraphicsTypes.h"
 
+#include <boost/filesystem/path.hpp>
+
 #include "support/std_string.h"
 
 /// This contains the runtime configuration of LyX
@@ -201,7 +203,7 @@ enum LyXRCTags {
 	///
 	string document_path;
 	///
-	string template_path;
+	boost::filesystem::path template_path;
 	///
 	string tempdir_path;
 	///
@@ -213,7 +215,7 @@ enum LyXRCTags {
 	///
 	bool check_lastfiles;
 	/// filename for lastfiles file
-	string lastfiles;
+	boost::filesystem::path lastfiles;
 	/// maximal number of lastfiles
 	unsigned int num_lastfiles;
 	/// shall a backup file be created
Index: src/main.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/main.C,v
retrieving revision 1.26
diff -u -p -r1.26 main.C
--- src/main.C	16 Sep 2003 11:03:18 -0000	1.26
+++ src/main.C	6 Oct 2003 01:05:48 -0000
@@ -15,6 +15,8 @@
 #include "gettext.h"
 #include "support/os.h"
 
+#include <boost/filesystem/operations.hpp>
+
 #ifdef HAVE_IOS
 #include <ios>
 #endif
@@ -28,6 +30,10 @@ int main(int argc, char * argv[])
 #ifdef HAVE_IOS
 	std::ios_base::sync_with_stdio(false);
 #endif
+
+	// Make sure that this is done before any other
+	// operations that may change cwd.
+	boost::filesystem::initial_path();
 
 	os::init(&argc, &argv);
 
Index: src/messages.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/messages.C,v
retrieving revision 1.14
diff -u -p -r1.14 messages.C
--- src/messages.C	9 Sep 2003 22:13:28 -0000	1.14
+++ src/messages.C	6 Oct 2003 01:05:48 -0000
@@ -16,6 +16,8 @@
 using lyx::support::GetEnvPath;
 using lyx::support::lyx_localedir;
 
+namespace fs = boost::filesystem;
+
 
 #ifdef ENABLE_NLS
 
@@ -23,21 +25,21 @@ namespace {
 
 string const & getLocaleDir()
 {
-	static string locale_dir;
+	static fs::path locale_dir;
 
 	if (locale_dir.empty()) {
 		locale_dir = GetEnvPath("LYX_LOCALEDIR");
 		if (locale_dir.empty())
 			locale_dir = lyx_localedir();
 	}
-	return locale_dir;
+	return locale_dir.string();
 }
 
 } // anon namespace
 
 #if 0
 
--#include <locale>
+#include <locale>
 
 // This version of the Pimpl utilizes the message capability of
 // libstdc++ that is distributed with GNU G++.
Index: src/vc-backend.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/vc-backend.C,v
retrieving revision 1.46
diff -u -p -r1.46 vc-backend.C
--- src/vc-backend.C	15 Sep 2003 10:59:54 -0000	1.46
+++ src/vc-backend.C	6 Oct 2003 01:05:48 -0000
@@ -21,11 +21,9 @@
 #include "support/systemcall.h"
 
 #include <boost/regex.hpp>
-
-#include <fstream>
+#include <boost/filesystem/fstream.hpp>
 
 using lyx::support::AddName;
-using lyx::support::AddPath;
 using lyx::support::contains;
 using lyx::support::FileInfo;
 using lyx::support::OnlyFilename;
@@ -39,6 +37,8 @@ using boost::regex;
 using boost::regex_match;
 using boost::smatch;
 
+namespace fs = boost::filesystem;
+
 #ifndef CXX_GLOBAL_CSTD
 using std::asctime;
 using std::gmtime;
@@ -69,26 +69,29 @@ RCS::RCS(string const & m)
 
 string const RCS::find_file(string const & file)
 {
-	string tmp(file);
+	string vcsname(file);
+	vcsname += ",v";
+
+	fs::path tmp = vcsname;
+
 	// Check if *,v exists.
-	tmp += ",v";
 	FileInfo f;
 	lyxerr[Debug::LYXVC] << "Checking if file is under rcs: "
-			     << tmp << endl;
+			     << vcsname << endl;
 	if (f.newFile(tmp).readable()) {
 		lyxerr[Debug::LYXVC] << "Yes " << file
 				     << " is under rcs." << endl;
-		return tmp;
+		return vcsname;
 	} else {
 		// Check if RCS/*,v exists.
-		tmp = AddName(AddPath(OnlyPath(file), "RCS"), file);
-		tmp += ",v";
+		vcsname = fs::path(file).leaf() + ",v";
+		tmp = fs::path(file).branch_path() / "RCS" / file;
 		lyxerr[Debug::LYXVC] << "Checking if file is under rcs: "
-				     << tmp << endl;
+				     << tmp.string() << endl;
 		if (f.newFile(tmp).readable()) {
 			lyxerr[Debug::LYXVC] << "Yes " << file
 					     << " it is under rcs."<< endl;
-			return tmp;
+			return tmp.string();
 		}
 	}
 	return string();
@@ -235,20 +238,20 @@ string const CVS::find_file(string const
 {
 	// First we look for the CVS/Entries in the same dir
 	// where we have file.
-	string const dir = OnlyPath(file) + "/CVS/Entries";
+	fs::path const dir = fs::path(file).branch_path() / "CVS/Entries";
 	string const tmpf = "/" + OnlyFilename(file) + "/";
-	lyxerr[Debug::LYXVC] << "LyXVC: checking in `" << dir
+	lyxerr[Debug::LYXVC] << "LyXVC: checking in `" << dir.string()
 			     << "' for `" << tmpf << '\'' << endl;
 	FileInfo const f(dir);
 	if (f.readable()) {
 		// Ok we are at least in a CVS dir. Parse the CVS/Entries
 		// and see if we can find this file. We do a fast and
 		// dirty parse here.
-		ifstream ifs(dir.c_str());
+		fs::ifstream ifs(dir);
 		string line;
 		while (getline(ifs, line)) {
 			lyxerr[Debug::LYXVC] << "\tEntries: " << line << endl;
-			if (contains(line, tmpf)) return dir;
+			if (contains(line, tmpf)) return dir.string();
 		}
 	}
 	return string();
Index: src/frontends/controllers/ControlAboutlyx.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlAboutlyx.C,v
retrieving revision 1.24
diff -u -p -r1.24 ControlAboutlyx.C
--- src/frontends/controllers/ControlAboutlyx.C	15 Sep 2003 10:59:55 -0000	1.24
+++ src/frontends/controllers/ControlAboutlyx.C	6 Oct 2003 01:05:48 -0000
@@ -37,7 +37,7 @@ ControlAboutlyx::ControlAboutlyx(Dialog 
 
 void ControlAboutlyx::getCredits(ostream & ss) const
 {
-	string const name = FileSearch(system_lyxdir(), "CREDITS");
+	string const name = FileSearch(system_lyxdir().string(), "CREDITS");
 
 	bool found(!name.empty());
 
@@ -84,10 +84,10 @@ string const ControlAboutlyx::getVersion
 	   << lyx_release_date
 	   << "\n"
 	   << _("Library directory: ")
-	   << MakeDisplayPath(system_lyxdir())
+	   << MakeDisplayPath(system_lyxdir().string())
 	   << "\n"
 	   << _("User directory: ")
-	   << MakeDisplayPath(user_lyxdir());
+	   << MakeDisplayPath(user_lyxdir().string());
 
 	return ss.str();
 }
Index: src/frontends/controllers/ControlDocument.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlDocument.C,v
retrieving revision 1.40
diff -u -p -r1.40 ControlDocument.C
--- src/frontends/controllers/ControlDocument.C	21 Sep 2003 16:02:53 -0000	1.40
+++ src/frontends/controllers/ControlDocument.C	6 Oct 2003 01:05:48 -0000
@@ -32,10 +32,11 @@
 #include "support/path_defines.h"
 
 using lyx::support::AddName;
-using lyx::support::AddPath;
 using lyx::support::bformat;
 using lyx::support::user_lyxdir;
 
+namespace fs = boost::filesystem;
+
 
 ControlDocument::ControlDocument(LyXView & lv, Dialogs & d)
 	: ControlDialogBD(lv, d), bp_(0)
@@ -167,9 +168,9 @@ void ControlDocument::saveAsDefault()
 
 	lv_.buffer()->params().preamble = bp_->preamble;
 
-	string const fname = AddName(AddPath(user_lyxdir(), "templates/"),
-				     "defaults.lyx");
-	Buffer defaults(fname);
+	fs::path const fname = user_lyxdir() / "templates/defaults.lyx";
+
+	Buffer defaults(fname.string());
 	defaults.params() = params();
 
 	// add an empty paragraph. Is this enough?
Index: src/frontends/controllers/ControlGraphics.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlGraphics.C,v
retrieving revision 1.80
diff -u -p -r1.80 ControlGraphics.C
--- src/frontends/controllers/ControlGraphics.C	9 Sep 2003 22:13:39 -0000	1.80
+++ src/frontends/controllers/ControlGraphics.C	6 Oct 2003 01:05:48 -0000
@@ -39,6 +39,8 @@ using lyx::support::readBB_from_PSFile;
 using lyx::support::system_lyxdir;
 using lyx::support::user_lyxdir;
 
+namespace fs = boost::filesystem;
+
 using std::make_pair;
 
 using std::pair;
@@ -79,12 +81,13 @@ string const ControlGraphics::Browse(str
 	string const title = _("Select graphics file");
 
 	// Does user clipart directory exist?
-	string clipdir = AddName (user_lyxdir(), "clipart");
-	FileInfo fileInfo(clipdir);
+	fs::path clipdir = user_lyxdir() / "clipart";
+
+	FileInfo fileInfo(clipdir.string());
 	if (!(fileInfo.isOK() && fileInfo.isDir()))
 		// No - bail out to system clipart directory
-		clipdir = AddName (system_lyxdir(), "clipart");
-	pair<string, string> dir1(_("Clipart|#C#c"), clipdir);
+		clipdir = system_lyxdir() / "clipart";
+	pair<string, string> dir1(_("Clipart|#C#c"), clipdir.string());
 	pair<string, string> dir2(_("Documents|#o#O"), string(lyxrc.document_path));
 	// Show the file browser dialog
 	return browseRelFile(in_name, kernel().bufferFilepath(),
Index: src/frontends/controllers/ControlPrefs.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlPrefs.C,v
retrieving revision 1.22
diff -u -p -r1.22 ControlPrefs.C
--- src/frontends/controllers/ControlPrefs.C	18 Sep 2003 11:48:08 -0000	1.22
+++ src/frontends/controllers/ControlPrefs.C	6 Oct 2003 01:05:48 -0000
@@ -35,6 +35,8 @@ using lyx::support::AddName;
 using lyx::support::system_lyxdir;
 using lyx::support::user_lyxdir;
 
+namespace fs = boost::filesystem;
+
 using std::pair;
 
 
@@ -67,15 +69,17 @@ void ControlPrefs::apply()
 
 string const ControlPrefs::browsebind(string const & file)
 {
-	string dir  = AddName(system_lyxdir(), "bind");
+	fs::path dir  = system_lyxdir() / "bind";
+
 	// FIXME: stupid name
 	string name = _("System Bind|#S#s");
-	pair<string,string> dir1(name, dir);
+	pair<string,string> dir1(name, dir.string());
+
+	dir = user_lyxdir() / "bind";
 
-	dir = AddName(user_lyxdir(), "bind");
 	// FIXME: stupid name
 	name = _("User Bind|#U#u");
-	pair<string,string> dir2(name, dir);
+	pair<string,string> dir2(name, dir.string());
 
 	return browseFile(file, _("Choose bind file"), "*.bind", false, dir1, dir2);
 }
@@ -83,15 +87,17 @@ string const ControlPrefs::browsebind(st
 
 string const ControlPrefs::browseUI(string const & file)
 {
-	string dir  = AddName(system_lyxdir(), "ui");
+	fs::path dir  = system_lyxdir() / "ui";
+	
 	// FIXME: stupid name
 	string name = _("Sys UI|#S#s");
-	pair<string,string> dir1(name, dir);
+	pair<string,string> dir1(name, dir.string());
 
-	dir = AddName(user_lyxdir(), "ui");
+	dir = user_lyxdir() / "ui";
+	
 	// FIXME: stupid name
 	name = _("User UI|#U#u");
-	pair<string,string> dir2(name, dir);
+	pair<string,string> dir2(name, dir.string());
 
 	return browseFile(file, _("Choose UI file"), "*.ui", false, dir1, dir2);
 }
@@ -99,9 +105,10 @@ string const ControlPrefs::browseUI(stri
 
 string const ControlPrefs::browsekbmap(string const & file)
 {
-	string const dir = AddName(system_lyxdir(), "kbd");
+	fs::path const dir = system_lyxdir() / "kbd";
+	
 	string const name = _("Key maps|#K#k");
-	pair<string, string> dir1(name, dir);
+	pair<string, string> dir1(name, dir.string());
 
 	return browseFile(file, _("Choose keyboard map"), "*.kmap", false, dir1);
 }
Index: src/frontends/controllers/tex_helpers.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/tex_helpers.C,v
retrieving revision 1.20
diff -u -p -r1.20 tex_helpers.C
--- src/frontends/controllers/tex_helpers.C	15 Sep 2003 10:59:55 -0000	1.20
+++ src/frontends/controllers/tex_helpers.C	6 Oct 2003 01:05:49 -0000
@@ -44,7 +44,7 @@ using std::endl;
 void rescanTexStyles()
 {
 	// Run rescan in user lyx directory
-	Path p(user_lyxdir());
+	Path p(user_lyxdir().string());
 	Systemcall one;
 	one.startscript(Systemcall::Wait,
 			LibFileSearch("scripts", "TeXFiles.sh"));
@@ -54,7 +54,7 @@ void rescanTexStyles()
 void texhash()
 {
 	// Run texhash in user lyx directory
-	Path p(user_lyxdir());
+	Path p(user_lyxdir().string());
 
 	//path to texhash through system
 	Systemcall one;
Index: src/frontends/xforms/FormPreferences.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FormPreferences.C,v
retrieving revision 1.179
diff -u -p -r1.179 FormPreferences.C
--- src/frontends/xforms/FormPreferences.C	16 Sep 2003 09:01:12 -0000	1.179
+++ src/frontends/xforms/FormPreferences.C	6 Oct 2003 01:05:49 -0000
@@ -45,6 +45,8 @@ using lyx::support::strToDbl;
 using lyx::support::trim;
 using lyx::support::user_lyxdir;
 
+namespace fs = boost::filesystem;
+
 using std::endl;
 using std::make_pair;
 using std::max;
@@ -304,8 +306,8 @@ void FormPreferences::apply()
 
 	// The "Save" button has been pressed.
 	if (controller().isClosing() && colors_.modifiedXformsPrefs) {
-		string const filename =
-			AddName(user_lyxdir(), "preferences.xform");
+		fs::path const filename =
+			user_lyxdir() / "preferences.xform";
 		colors_.modifiedXformsPrefs = !XformsColor::write(filename);
 	}
 }
@@ -2030,7 +2032,7 @@ void FormPreferences::Paths::update(LyXR
 	fl_set_input(dialog_->input_default_path,
 		     rc.document_path.c_str());
 	fl_set_input(dialog_->input_template_path,
-		     rc.template_path.c_str());
+		     rc.template_path.string().c_str());
 
 	string str;
 	if (rc.make_backup)
@@ -2050,7 +2052,7 @@ void FormPreferences::Paths::update(LyXR
 
 	str.erase();
 	if (rc.check_lastfiles)
-		str = rc.lastfiles;
+		str = rc.lastfiles.string();
 
 	fl_set_button(dialog_->check_last_files,
 		      rc.check_lastfiles);
Index: src/frontends/xforms/lyx_gui.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/lyx_gui.C,v
retrieving revision 1.53
diff -u -p -r1.53 lyx_gui.C
--- src/frontends/xforms/lyx_gui.C	21 Sep 2003 16:02:54 -0000	1.53
+++ src/frontends/xforms/lyx_gui.C	6 Oct 2003 01:05:49 -0000
@@ -191,7 +191,7 @@ void parse_init(int & argc, char * argv[
 
 void parse_lyxrc()
 {
-	XformsColor::read(AddName(user_lyxdir(), "preferences.xform"));
+	XformsColor::read(user_lyxdir() / "preferences.xform");
 
 	if (lyxrc.popup_font_encoding.empty())
 		lyxrc.popup_font_encoding = lyxrc.font_norm;
Index: src/frontends/xforms/xforms_helpers.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/xforms_helpers.C,v
retrieving revision 1.70
diff -u -p -r1.70 xforms_helpers.C
--- src/frontends/xforms/xforms_helpers.C	15 Sep 2003 10:53:02 -0000	1.70
+++ src/frontends/xforms/xforms_helpers.C	6 Oct 2003 01:05:49 -0000
@@ -25,6 +25,7 @@
 #include "combox.h"
 
 #include <boost/assert.hpp>
+#include <boost/filesystem/fstream.hpp>
 
 #include <fstream>
 
@@ -35,6 +36,8 @@ using lyx::support::OnlyPath;
 using lyx::support::subst;
 using lyx::support::trim;
 
+namespace fs = boost::filesystem;
+
 using std::make_pair;
 
 using std::ofstream;
@@ -312,10 +315,10 @@ const int xformCount = sizeof(xformTags)
 } // namespace anon
 
 
-bool XformsColor::read(string const & filename)
+bool XformsColor::read(fs::path const & filename)
 {
 	LyXLex lexrc(xformTags, xformCount);
-	if (!lexrc.setFile(filename))
+	if (!lexrc.setFile(filename.string()))
 		return false;
 
 	while (lexrc.isOK()) {
@@ -354,14 +357,14 @@ bool XformsColor::read(string const & fi
 }
 
 
-bool XformsColor::write(string const & filename)
+bool XformsColor::write(fs::path const & filename)
 {
-	ofstream os(filename.c_str());
+	fs::ofstream os(filename);
 	if (!os)
 		return false;
 
 	os << "###"
-	   << "### file " << filename << "\n\n"
+	   << "### file " << filename.string() << "\n\n"
 	   << "### This file is written by LyX, if you want to make your own\n"
 	   << "### modifications you should do them from inside LyX and save\n"
 	   << '\n';
Index: src/frontends/xforms/xforms_helpers.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/xforms_helpers.h,v
retrieving revision 1.37
diff -u -p -r1.37 xforms_helpers.h
--- src/frontends/xforms/xforms_helpers.h	5 Sep 2003 17:23:02 -0000	1.37
+++ src/frontends/xforms/xforms_helpers.h	6 Oct 2003 01:05:50 -0000
@@ -16,6 +16,9 @@
 #include "forms_fwd.h"
 
 #include "Color.h"
+
+#include <boost/filesystem/path.hpp>
+
 #include "support/std_string.h"
 
 #include <algorithm>
@@ -94,8 +97,8 @@ void setCursorColor(int color);
 struct XformsColor : public NamedColor {
 	int colorID;
 	XformsColor() : NamedColor(), colorID(0) {}
-	static bool read(string const &);
-	static bool write(string const &);
+	static bool read(boost::filesystem::path const &);
+	static bool write(boost::filesystem::path const &);
 };
 
 
Index: src/insets/ExternalTemplate.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/ExternalTemplate.C,v
retrieving revision 1.30
diff -u -p -r1.30 ExternalTemplate.C
--- src/insets/ExternalTemplate.C	1 Oct 2003 10:16:00 -0000	1.30
+++ src/insets/ExternalTemplate.C	6 Oct 2003 01:05:50 -0000
@@ -25,6 +25,7 @@
 #include <algorithm>
 
 namespace support = lyx::support;
+namespace fs = boost::filesystem;
 
 using std::endl;
 using std::for_each;
@@ -190,9 +191,9 @@ TemplateManager::getPreambleDefByName(st
 }
 
 
-void TemplateManager::readTemplates(string const & path)
+void TemplateManager::readTemplates(fs::path const & template_path)
 {
-	support::Path p(path);
+	support::Path p(template_path.string());
 
 	enum TemplateTags {
 		TM_PREAMBLEDEF = 1,
Index: src/insets/ExternalTemplate.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/ExternalTemplate.h,v
retrieving revision 1.22
diff -u -p -r1.22 ExternalTemplate.h
--- src/insets/ExternalTemplate.h	1 Oct 2003 10:16:00 -0000	1.22
+++ src/insets/ExternalTemplate.h	6 Oct 2003 01:05:50 -0000
@@ -14,6 +14,8 @@
 
 #include <boost/function.hpp>
 #include <boost/utility.hpp>
+#include <boost/filesystem/path.hpp>
+
 #include "support/std_string.h"
 #include <iosfwd>
 #include <map>
@@ -100,7 +102,7 @@ public:
 	string const getPreambleDefByName(string const & name) const;
 private:
 	TemplateManager();
-	void readTemplates(string const & path);
+	void readTemplates(boost::filesystem::path const & template_path);
 	void dumpTemplates(std::ostream &) const;
 	void dumpPreambleDefs(std::ostream &) const;
 
Index: src/insets/insetexternal.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetexternal.C,v
retrieving revision 1.113
diff -u -p -r1.113 insetexternal.C
--- src/insets/insetexternal.C	1 Oct 2003 10:16:00 -0000	1.113
+++ src/insets/insetexternal.C	6 Oct 2003 01:05:50 -0000
@@ -611,7 +611,7 @@ string const doSubstitution(InsetExterna
 	result = support::subst(result, "$$Basename", basename);
 	result = support::subst(result, "$$FPath", filepath);
 	result = support::subst(result, "$$Tempname", params.tempname());
-	result = support::subst(result, "$$Sysdir", support::system_lyxdir());
+	result = support::subst(result, "$$Sysdir", support::system_lyxdir().string());
 
 	// Handle the $$Contents(filename) syntax
 	if (support::contains(result, "$$Contents(\"")) {
Index: src/support/FileInfo.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/FileInfo.C,v
retrieving revision 1.22
diff -u -p -r1.22 FileInfo.C
--- src/support/FileInfo.C	9 Sep 2003 17:25:34 -0000	1.22
+++ src/support/FileInfo.C	6 Oct 2003 01:05:50 -0000
@@ -16,6 +16,8 @@
 
 #include <cerrno>
 
+namespace fs = boost::filesystem;
+
 #if !S_IRUSR
 # if S_IREAD
 #  define S_IRUSR S_IREAD
@@ -150,7 +152,7 @@ FileInfo::FileInfo()
 }
 
 
-FileInfo::FileInfo(string const & path, bool link)
+FileInfo::FileInfo(fs::path const & path, bool link)
 	: fname_(path)
 {
 	init();
@@ -177,15 +179,15 @@ void FileInfo::init()
 void FileInfo::dostat(bool link)
 {
 	if (link)
-		status_ = ::lstat(fname_.c_str(), &buf_);
+		status_ = ::lstat(fname_.string().c_str(), &buf_);
 	else
-		status_ = ::stat(fname_.c_str(), &buf_);
+		status_ = ::stat(fname_.string().c_str(), &buf_);
 	if (status_)
 		err_ = errno;
 }
 
 
-FileInfo & FileInfo::newFile(string const & path, bool link)
+FileInfo & FileInfo::newFile(fs::path const & path, bool link)
 {
 	fname_  = path;
 	status_ = 0;
@@ -376,7 +378,7 @@ bool FileInfo::access(int p) const
 
 	// If we were really kind, we would also tell why
 	// the file access failed.
-	return ::access(fname_.c_str(), p) == 0;
+	return ::access(fname_.string().c_str(), p) == 0;
 }
 
 } // namespace support
Index: src/support/FileInfo.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/FileInfo.h,v
retrieving revision 1.27
diff -u -p -r1.27 FileInfo.h
--- src/support/FileInfo.h	5 Sep 2003 17:23:10 -0000	1.27
+++ src/support/FileInfo.h	6 Oct 2003 01:05:50 -0000
@@ -12,12 +12,15 @@
 #ifndef FILE_INFO_H
 #define FILE_INFO_H
 
+#include <boost/utility.hpp>
+#include <boost/filesystem/path.hpp>
+
 #include <ctime>
 
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
-#include <boost/utility.hpp>
+
 #include "support/std_string.h"
 
 namespace lyx {
@@ -36,13 +39,13 @@ public:
 	/** Get information about file.
 	    If link is true, the information is about the link itself, not
 	    the file that is obtained by tracing the links. */
-	explicit FileInfo(string const & path, bool link = false);
+	explicit FileInfo(boost::filesystem::path const & path, bool link = false);
 
 	/// File descriptor
 	explicit FileInfo(int fildes);
 
 	/// Query a new file
-	FileInfo & newFile(string const & path, bool link = false);
+	FileInfo & newFile(boost::filesystem::path const & path, bool link = false);
 
 	/// Query a new file descriptor
 	FileInfo & newFile(int fildes);
@@ -135,7 +138,7 @@ private:
 	///
 	int err_;
 	///
-	string fname_;
+	boost::filesystem::path fname_;
 };
 
 } // namespace support
Index: src/support/filetools.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/filetools.C,v
retrieving revision 1.174
diff -u -p -r1.174 filetools.C
--- src/support/filetools.C	29 Sep 2003 21:44:34 -0000	1.174
+++ src/support/filetools.C	6 Oct 2003 01:05:50 -0000
@@ -38,6 +38,7 @@
 
 #include <boost/assert.hpp>
 #include <boost/regex.hpp>
+#include <boost/filesystem/operations.hpp>
 
 #include <cctype>
 #include <cstdlib>
@@ -67,6 +68,8 @@
 # endif
 #endif
 
+namespace fs = boost::filesystem;
+
 #ifndef CXX_GLOBAL_CSTD
 using std::fgetc;
 using std::isalnum;
@@ -186,8 +189,8 @@ string const FileOpenSearch(string const
 		path_element = os::slashify_path(path_element);
 		if (!suffixIs(path_element, '/'))
 			path_element+= '/';
-		path_element = subst(path_element, "$$LyX", system_lyxdir());
-		path_element = subst(path_element, "$$User", user_lyxdir());
+		path_element = subst(path_element, "$$LyX", system_lyxdir().string());
+		path_element = subst(path_element, "$$User", user_lyxdir().string());
 
 		real_file = FileSearch(path_element, name, ext);
 
@@ -292,16 +295,16 @@ string const FileSearch(string const & p
 string const LibFileSearch(string const & dir, string const & name,
 			   string const & ext)
 {
-	string fullname = FileSearch(AddPath(user_lyxdir(), dir), name, ext);
+	string fullname = FileSearch((user_lyxdir() / dir).string(), name, ext);
 	if (!fullname.empty())
 		return fullname;
 
 	if (!build_lyxdir().empty())
-		fullname = FileSearch(AddPath(build_lyxdir(), dir), name, ext);
+		fullname = FileSearch((build_lyxdir() / dir).string(), name, ext);
 	if (!fullname.empty())
 		return fullname;
 
-	return FileSearch(AddPath(system_lyxdir(), dir), name, ext);
+	return FileSearch((system_lyxdir() / dir).string(), name, ext);
 }
 
 
@@ -544,62 +547,20 @@ string const OnlyPath(string const & Fil
 string const MakeAbsPath(string const & RelPath, string const & BasePath)
 {
 	// checks for already absolute path
-	if (os::is_absolute_path(RelPath))
+	if (fs::path(RelPath).is_complete())
 		return RelPath;
 
 	// Copies given paths
-	string TempRel(os::slashify_path(RelPath));
-	// Since TempRel is NOT absolute, we can safely replace "//" with "/"
-	TempRel = subst(TempRel, "//", "/");
-
-	string TempBase;
+	fs::path TempRel(RelPath);
+	
+	fs::path TempBase;
 
-	if (os::is_absolute_path(BasePath))
+	if (fs::path(BasePath).is_complete())
 		TempBase = BasePath;
 	else
-		TempBase = AddPath(getcwd(), BasePath);
-
-	// Handle /./ at the end of the path
-	while (suffixIs(TempBase, "/./"))
-		TempBase.erase(TempBase.length() - 2);
-
-	// processes relative path
-	string RTemp(TempRel);
-	string Temp;
-
-	while (!RTemp.empty()) {
-		// Split by next /
-		RTemp = split(RTemp, Temp, '/');
-
-		if (Temp == ".") continue;
-		if (Temp == "..") {
-			// Remove one level of TempBase
-			string::difference_type i = TempBase.length() - 2;
-#ifndef __EMX__
-			if (i < 0) i = 0;
-			while (i > 0 && TempBase[i] != '/') --i;
-			if (i > 0)
-#else
-			if (i < 2) i = 2;
-			while (i > 2 && TempBase[i] != '/') --i;
-			if (i > 2)
-#endif
-				TempBase.erase(i, string::npos);
-			else
-				TempBase += '/';
-		} else if (Temp.empty() && !RTemp.empty()) {
-				TempBase = os::current_root() + RTemp;
-				RTemp.erase();
-		} else {
-			// Add this piece to TempBase
-			if (!suffixIs(TempBase, '/'))
-				TempBase += '/';
-			TempBase += Temp;
-		}
-	}
+		TempBase = fs::current_path() / BasePath;
 
-	// returns absolute path
-	return os::slashify_path(TempBase);
+	return fs::complete(TempRel, TempBase).string();
 }
 
 
@@ -807,28 +768,6 @@ string const MakeRelPath(string const & 
 	// Substitute empty with .
 	if (buf.empty())
 		buf = '.';
-	return buf;
-}
-
-
-// Append sub-directory(ies) to a path in an intelligent way
-string const AddPath(string const & path, string const & path_2)
-{
-	string buf;
-	string const path2 = os::slashify_path(path_2);
-
-	if (!path.empty() && path != "." && path != "./") {
-		buf = os::slashify_path(path);
-		if (path[path.length() - 1] != '/')
-			buf += '/';
-	}
-
-	if (!path2.empty()) {
-		string::size_type const p2start = path2.find_first_not_of('/');
-		string::size_type const p2end = path2.find_last_not_of('/');
-		string const tmp = path2.substr(p2start, p2end - p2start + 1);
-		buf += tmp + '/';
-	}
 	return buf;
 }
 
Index: src/support/filetools.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/filetools.h,v
retrieving revision 1.52
diff -u -p -r1.52 filetools.h
--- src/support/filetools.h	5 Sep 2003 17:23:10 -0000	1.52
+++ src/support/filetools.h	6 Oct 2003 01:05:51 -0000
@@ -123,9 +123,6 @@ string const QuoteName(string const & fi
 /// Add a filename to a path. Any path from filename is stripped first.
 string const AddName(string const & path, string const & fname);
 
-/// Append sub-directory(ies) to path in an intelligent way
-string const AddPath(string const & path, string const & path2);
-
 /** Change extension of oldname to extension.
  If oldname does not have an extension, it is appended.
  If the extension is empty, any extension is removed from the name.
Index: src/support/path.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/path.C,v
retrieving revision 1.10
diff -u -p -r1.10 path.C
--- src/support/path.C	4 Sep 2003 01:44:16 -0000	1.10
+++ src/support/path.C	6 Oct 2003 01:05:51 -0000
@@ -16,15 +16,19 @@
 #include "path.h"
 #include "lyxlib.h"
 
+#include <boost/filesystem/operations.hpp>
+
+namespace fs = boost::filesystem;
+
 namespace lyx {
 namespace support {
 
-Path::Path(string const & path)
+Path::Path(fs::path const & dir)
 	: popped_(false)
 {
-	if (!path.empty()) {
-		pushedDir_ = getcwd();
-		if (pushedDir_.empty() || chdir(path))
+	if (!dir.empty()) {
+		pushedDir_ = fs::current_path();
+		if (pushedDir_.empty() || chdir(dir.string()))
 			/* FIXME: throw */;
 	} else {
 		popped_ = true;
@@ -46,7 +50,7 @@ int Path::pop()
 		return 0;
 	}
 
-	if (chdir(pushedDir_)) {
+	if (chdir(pushedDir_.string())) {
 		// should throw an exception
 		// throw DirChangeError();
 	}
Index: src/support/path.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/path.h,v
retrieving revision 1.22
diff -u -p -r1.22 path.h
--- src/support/path.h	5 Sep 2003 17:23:10 -0000	1.22
+++ src/support/path.h	6 Oct 2003 01:05:51 -0000
@@ -12,9 +12,10 @@
 #ifndef PATH_H
 #define PATH_H
 
-#include "support/std_string.h"
 #include <boost/utility.hpp>
+#include <boost/filesystem/path.hpp>
 
+#include "support/std_string.h"
 namespace lyx {
 namespace support {
 
@@ -34,7 +35,7 @@ namespace support {
 class Path : boost::noncopyable {
 public:
 	/// change to the given directory
-	explicit Path(string const & path);
+	explicit Path(boost::filesystem::path const & dir);
 
 	/// set cwd to the previous value if needed
 	~Path();
@@ -45,7 +46,7 @@ private:
 	/// whether we are in the new cwd or not
 	bool popped_;
 	/// the previous cwd
-	string pushedDir_;
+	boost::filesystem::path pushedDir_;
 };
 
 // To avoid the wrong usage:
Index: src/support/path_defines.C.in
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/path_defines.C.in,v
retrieving revision 1.7
diff -u -p -r1.7 path_defines.C.in
--- src/support/path_defines.C.in	22 Aug 2003 09:44:59 -0000	1.7
+++ src/support/path_defines.C.in	6 Oct 2003 01:05:51 -0000
@@ -24,27 +24,31 @@
 #include "lstrings.h"
 #include "os.h"
 
+#include <boost/filesystem/operations.hpp>
+
+namespace fs = boost::filesystem;
+
 using std::endl;
 
 
 namespace {
 
 // Store for the path to the lyx support files we're actually going to use.
-string system_lyxdir_;
+fs::path system_lyxdir_;
 
 // Store for the path to the autogenerated files when running in place
-string build_lyxdir_;
+fs::path build_lyxdir_;
 
 // Store for the path to the user-level support files.
-string user_lyxdir_;
+fs::path user_lyxdir_;
 
 
 /* The absolute path to the system-level lyx support files.
  * (Make-time value.)
  */
-string const & lyx_dir()
+fs::path const & lyx_dir()
 {
-	static string const ld = "%LYX_DIR%";
+	static fs::path const ld("%LYX_DIR%");
 	return ld;
 }
 
@@ -52,9 +56,9 @@ string const & lyx_dir()
 /* The absolute path to the top of the lyx build tree.
  * (Make-time value.)
  */
-string const & lyx_top_srcdir()
+fs::path const & lyx_top_srcdir()
 {
-	static string const lts = "%TOP_SRCDIR%";
+	static fs::path const lts("%TOP_SRCDIR%");
 	return lts;
 }
 
@@ -68,51 +72,51 @@ namespace support {
 /* The absolute path to the system-level lyx locale directory.
  * (Make-time value.)
  */
-string const & lyx_localedir()
+fs::path const & lyx_localedir()
 {
-	static string const ll = "%LOCALEDIR%";
+	static fs::path const ll("%LOCALEDIR%");
 	return ll;
 }
 
 
-string const & build_dir()
+fs::path const & build_dir()
 {
-	static string const bl = "%BUILDDIR%";
+	static fs::path const bl("%BUILDDIR%");
 	return bl;
 }
 
 
-string const & build_lyxdir()
+fs::path const & build_lyxdir()
 {
 	return build_lyxdir_;
 }
 
 
-void build_lyxdir(string const & sld)
+void build_lyxdir(fs::path const & sld)
 {
 	build_lyxdir_ = sld;
 }
 
 
-string const & system_lyxdir()
+fs::path const & system_lyxdir()
 {
 	return system_lyxdir_;
 }
 
 
-void system_lyxdir(string const & sld)
+void system_lyxdir(fs::path const & sld)
 {
 	system_lyxdir_ = sld;
 }
 
 
-string const & user_lyxdir()
+fs::path const & user_lyxdir()
 {
 	return user_lyxdir_;
 }
 
 
-void user_lyxdir(string const & uld)
+void user_lyxdir(fs::path const & uld)
 {
 	user_lyxdir_ = uld;
 }
@@ -124,9 +128,9 @@ bool setLyxPaths()
 	// Determine path of binary
 	//
 
-	string binpath = os::binpath();
-	string binname = os::binname();
-	string fullbinname = MakeAbsPath(binname, binpath);
+	fs::path binpath = os::binpath();
+	fs::path binname = os::binname();
+	fs::path fullbinname = fs::complete(binname, binpath);
 
 	if (binpath.empty()) {
 		lyxerr << _("Warning: could not determine path of binary.")
@@ -134,8 +138,8 @@ bool setLyxPaths()
 		       << _("If you have problems, try starting LyX with an absolute path.")
 		       << endl;
 	}
-	lyxerr[Debug::INIT] << "Name of binary: " << binname << endl;
-	lyxerr[Debug::INIT] << "Path of binary: " << binpath << endl;
+	lyxerr[Debug::INIT] << "Name of binary: " << binname.string() << endl;
+	lyxerr[Debug::INIT] << "Path of binary: " << binpath.string() << endl;
 
 
 	string searchpath;
@@ -145,9 +149,9 @@ bool setLyxPaths()
 	// build_lyxdir accordingly
 	//
 
-	string const buildlyxdir = MakeAbsPath("../lib", binpath);
-	if (!FileSearch(buildlyxdir, "lyxrc.defaults").empty()) {
-		searchpath += AddPath(lyx_top_srcdir(), "lib") + ';';
+	fs::path const buildlyxdir = fs::complete(fs::path("../lib") / binpath);
+	if (!FileSearch(buildlyxdir.string(), "lyxrc.defaults").empty()) {
+		searchpath += (lyx_top_srcdir() / "lib").string() + ';';
 		build_lyxdir(buildlyxdir);
 		lyxerr[Debug::INIT] << "Checking whether LyX is run in "
 			"place... yes" << endl;
@@ -177,7 +181,7 @@ bool setLyxPaths()
 
 	// If we had a command line switch, system_lyxdir_ is already set
 	if (!system_lyxdir_.empty())
-		searchpath = MakeAbsPath(system_lyxdir_) + ';';
+		searchpath = fs::complete(system_lyxdir_).string() + ';';
 
 	string const lyxdir = GetEnvPath("LYX_DIR_14x");
 
@@ -186,38 +190,35 @@ bool setLyxPaths()
 		searchpath += lyxdir + ';';
 	}
 
-	string fullbinpath = binpath;
+	fs::path fullbinpath = binpath;
 	FileInfo file(fullbinname, true);
 	if (file.isLink()) {
 		lyxerr[Debug::INIT] << "binary is a link" << endl;
 		string link;
-		if (LyXReadLink(fullbinname, link, true)) {
+		if (LyXReadLink(fullbinname.string(), link, true)) {
 			// Path of binary/../share/name of binary/
-			searchpath += NormalizePath(AddPath(binpath,
-							    "../share/")
-						    + OnlyFilename(binname));
+			searchpath += (binpath / "../share/" / binname.leaf()).string();
 			searchpath += ';';
 			fullbinpath = link;
-			binpath = MakeAbsPath(OnlyPath(fullbinpath));
+			binpath = fs::complete(fullbinpath.branch_path());
 		}
 	}
 
 	bool followlink;
 	do {
 		// Path of binary/../share/name of binary/
-		searchpath += NormalizePath(AddPath(binpath, "../share/") +
-		      OnlyFilename(binname)) + ';';
+		searchpath += (binpath / "../share/" / binname).string() + ';';
 
 		// Follow Symlinks
 		FileInfo file(fullbinpath, true);
 		followlink = file.isLink();
 		if (followlink) {
-			lyxerr[Debug::INIT] << " directory " << fullbinpath
+			lyxerr[Debug::INIT] << " directory " << fullbinpath.string()
 					    << " is a link" << endl;
 			string link;
-			if (LyXReadLink(fullbinpath, link, true)) {
+			if (LyXReadLink(fullbinpath.string(), link, true)) {
 				fullbinpath = link;
-				binpath = MakeAbsPath(OnlyPath(fullbinpath));
+				binpath = fs::complete(fullbinpath.branch_path());
 			}
 			else {
 				followlink = false;
@@ -226,49 +227,49 @@ bool setLyxPaths()
 	} while (followlink);
 
 	// <absolute top srcdir>/lib
-	searchpath += AddPath(lyx_top_srcdir(), "lib") + ';';
+	searchpath += (lyx_top_srcdir() / "lib").string() + ';';
 	// Hardcoded dir
-	searchpath += lyx_dir();
+	searchpath += lyx_dir().string();
 
 	lyxerr[Debug::INIT] << "System directory search path: "
 			    << searchpath << endl;
 
 	string const filename = "chkconfig.ltx";
-	string const temp = FileOpenSearch(searchpath, filename, string());
-	system_lyxdir_ = OnlyPath(temp);
+	fs::path const temp = FileOpenSearch(searchpath, filename, string());
+	system_lyxdir_ = temp.branch_path();
 
 	// Reduce "path/../path" stuff out of system directory
-	system_lyxdir_ = NormalizePath(system_lyxdir_);
+	system_lyxdir_ = NormalizePath(system_lyxdir_.string());
 
 	bool path_shown = false;
 
 	// Warn if environment variable is set, but unusable
 	if (!lyxdir.empty()) {
-		if (system_lyxdir_ != NormalizePath(lyxdir)) {
+		if (system_lyxdir_.string() != fs::path(NormalizePath(lyxdir)).string()) {
 			lyxerr <<_("LYX_DIR_14x environment variable no good.")
 			       << '\n'
 			       << _("System directory set to: ")
-			       << system_lyxdir_ << endl;
+			       << system_lyxdir_.string() << endl;
 			path_shown = true;
 		}
 	}
 
 	// Warn the user if we couldn't find "chkconfig.ltx"
-	if (system_lyxdir_ == "./") {
+	if (system_lyxdir_.empty()) {
 		lyxerr <<_("LyX Warning! Couldn't determine system directory. ")
 		       <<_("Try the '-sysdir' command line parameter or ")
 		       <<_("set the environment variable LYX_DIR_14x to the "
 			   "LyX system directory ")
 		       << _("containing the file `chkconfig.ltx'.") << endl;
 		if (!path_shown) {
-			FileInfo fi(lyx_dir());
+			FileInfo fi(lyx_dir().string());
 			if (!fi.exist()) {
 				lyxerr << "Couldn't even find the default LYX_DIR." << endl
 					<< "Giving up." << endl;
 				exit(1);
 			}
 			lyxerr << bformat(_("Using built-in default %1$s but expect problems."),
-				lyx_dir()) << endl;
+				lyx_dir().string()) << endl;
 		} else {
 			lyxerr << _("Expect problems.") << endl;
 		}
@@ -278,7 +279,7 @@ bool setLyxPaths()
 
 	if (!path_shown)
 		lyxerr[Debug::INIT] << "System directory: '"
-				    << system_lyxdir_ << '\'' << endl;
+				    << system_lyxdir_.string() << '\'' << endl;
 
 	//
 	// Determine user lyx-dir
@@ -298,13 +299,12 @@ bool setLyxPaths()
 
 		// default behaviour
 		if (user_lyxdir_.empty())
-			user_lyxdir_ = AddPath(GetEnvPath("HOME"),
-					       string(".") + PACKAGE);
+			user_lyxdir_ = fs::path(GetEnvPath("HOME")) / (string(".") + PACKAGE);
 			explicit_userdir = false;
 	}
 
 	lyxerr[Debug::INIT] << "User LyX directory: '"
-			    <<  user_lyxdir_ << '\'' << endl;
+			    <<  user_lyxdir_.string() << '\'' << endl;
 	return explicit_userdir;
 }
 
Index: src/support/path_defines.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/path_defines.h,v
retrieving revision 1.8
diff -u -p -r1.8 path_defines.h
--- src/support/path_defines.h	5 Sep 2003 17:23:10 -0000	1.8
+++ src/support/path_defines.h	6 Oct 2003 01:05:51 -0000
@@ -14,25 +14,27 @@
 
 #include "support/std_string.h"
 
+#include <boost/filesystem/path.hpp>
+
 namespace lyx {
 namespace support {
 
-string const & lyx_localedir();
+boost::filesystem::path const & lyx_localedir();
 
 /// The absolute path to the lyx support files we're actually going to use.
-string const & system_lyxdir();
+boost::filesystem::path const & system_lyxdir();
 
 /// Set the absolute path to the lyx support files (from the command line).
-void system_lyxdir(string const &);
+void system_lyxdir(boost::filesystem::path const &);
 
 /// The absolute path to the lyx support files in the build directory
-string const & build_lyxdir();
+boost::filesystem::path const & build_lyxdir();
 
 /// The absolute path to the user-level lyx support files.
-string const & user_lyxdir();
+boost::filesystem::path const & user_lyxdir();
 
 /// Set the absolute path to the user-level lyx support files.
-void user_lyxdir(string const &);
+void user_lyxdir(boost::filesystem::path const &);
 
 /** \returns true if the user lyx dir existed already and did not need
  *  to be created afresh.
Index: src/tex2lyx/Makefile.am
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/tex2lyx/Makefile.am,v
retrieving revision 1.13
diff -u -p -r1.13 Makefile.am
--- src/tex2lyx/Makefile.am	7 Aug 2003 22:59:53 -0000	1.13
+++ src/tex2lyx/Makefile.am	6 Oct 2003 01:05:51 -0000
@@ -45,6 +45,7 @@ tex2lyx_SOURCES = \
 
 tex2lyx_LDADD = \
 	../support/libsupport.la \
+	../../boost/libs/filesystem/src/libboostfilesystem.la \
 	../../boost/libs/regex/src/libboostregex.la -lz
 
 FloatList.C: link_files
-- 
        Lgb

Reply via email to