FileName const get_document_dir(FileName const & home_dir);
-FileName const get_home_dir();
-
FileName const get_locale_dir(FileName const & system_support_dir);
FileName const get_system_support_dir(FileName const & abs_binary,
bool userSupportDir(FileName const & default_user_support_dir,
string const & command_line_user_support_dir, FileName & result);
-
string const & with_version_suffix();
+string const fix_dir_name(string const & name);
+
} // namespace anon
exe_build_dir_to_top_build_dir top_build_dir_location)
: explicit_user_support_dir_(false)
{
- home_dir_ = get_home_dir();
// Specification of temp_dir_ may be reset by LyXRC,
// but the default is fixed for a given OS.
system_temp_dir_ = FileName::tempPath();
temp_dir_ = system_temp_dir_;
- document_dir_ = get_document_dir(home_dir_);
+ document_dir_ = get_document_dir(get_home_dir());
FileName const abs_binary = abs_path_from_binary_name(command_line_arg0);
binary_dir_ = FileName(onlyPath(abs_binary.absFileName()));
locale_dir_ = get_locale_dir(system_support_dir_);
FileName const default_user_support_dir =
- get_default_user_support_dir(home_dir_);
+ get_default_user_support_dir(get_home_dir());
explicit_user_support_dir_ = userSupportDir(default_user_support_dir,
command_line_user_support_dir, user_support_dir_);
<< "\tlocale_dir " << locale_dir().absFileName() << '\n'
<< "\tdocument_dir " << document_dir().absFileName() << '\n'
<< "\ttemp_dir " << temp_dir().absFileName() << '\n'
- << "\thome_dir " << home_dir().absFileName() << '\n'
+ << "\thome_dir " << get_home_dir().absFileName() << '\n'
<< "</package>\n");
}
temp_dir_ = temp_dir;
}
+// The specification of home_dir_ is fixed for a given OS.
+// A typical example on Windows: "C:/Documents and Settings/USERNAME"
+// and on a Posix-like machine: "/home/USERNAME".
+FileName const & Package::get_home_dir()
+{
+#if defined (USE_WINDOWS_PACKAGING)
+ static FileName const home_dir(getEnv("USERPROFILE"));
+#else // Posix-like.
+ static FileName const home_dir(getEnv("HOME"));
+#endif
+ return home_dir;
+}
+
namespace {
}
-// The specification of home_dir_ is fixed for a given OS.
-// A typical example on Windows: "C:/Documents and Settings/USERNAME"
-// and on a Posix-like machine: "/home/USERNAME".
-FileName const get_home_dir()
-{
-#if defined (USE_WINDOWS_PACKAGING)
- string const home_dir = getEnv("USERPROFILE");
-#else // Posix-like.
- string const home_dir = getEnv("HOME");
-#endif
-
- return FileName(fix_dir_name(home_dir));
-}
-
// Several sources are probed to ascertain the locale directory.
// The only requirement is that the result is indeed a directory.
* for the dump.
* This may be empty (e. g. when run under a CGI environment)
*/
- FileName const & home_dir() const { return home_dir_; }
+ static FileName const & get_home_dir();
/** Command to run the configure script.
* Caution: This is "ready-to-run", i.e. in the locale encoding, not
mutable FileName document_dir_;
mutable FileName temp_dir_;
FileName system_temp_dir_;
- FileName home_dir_;
std::string configure_command_;
bool explicit_user_support_dir_;
};
// Split by first /
rTemp = split(rTemp, temp, '/');
if (temp == "~") {
- tempBase = package().home_dir().absFileName();
+ tempBase = Package::get_home_dir().absFileName();
tempRel = rTemp;
}
return FileName::getcwd().absFileName() + '/' + rTemp;
if (temp == "~")
- return package().home_dir().absFileName() + '/' + rTemp;
+ return Package::get_home_dir().absFileName() + '/' + rTemp;
if (temp == "..")
return makeAbsPath(copy).absFileName();
return from_utf8("[" + str.erase(0, system.length()) + "]");
// replace /home/blah with ~/
- string const home = package().home_dir().absFileName();
+ string const home = Package::get_home_dir().absFileName();
if (!home.empty() && prefixIs(str, home))
str = subst(str, home, "~");