]> git.lyx.org Git - lyx.git/blobdiff - src/support/path_defines.C.in
tostr -> convert and some bformat work
[lyx.git] / src / support / path_defines.C.in
index f3a0c5eaf64e7811859126e5bd872d59161f4ebf..dfe7062efb274395531da49a61478c172be4b5a8 100644 (file)
@@ -217,8 +217,18 @@ bool setLyxPaths()
        bool followlink;
        do {
                // Path of binary/../share/name of binary/
-               searchpath += NormalizePath(AddPath(binpath, "../share/") +
-                     OnlyFilename(binname)) + ';';
+               string const exe_name = OnlyFilename(binname);
+#ifdef _WIN32
+               string const lyx_system_dir_name =
+                       suffixIs(exe_name, ".exe") ?
+                               ChangeExtension(exe_name, "") :
+                               exe_name;
+#else
+               string const lyx_system_dir_name = exe_name;
+#endif
+               string const shared_dir_name =
+                       NormalizePath(AddPath(binpath, "../share/"));
+               searchpath += shared_dir_name + lyx_system_dir_name + ';';
 
                // Follow Symlinks
                FileInfo file(fullbinpath, true);
@@ -294,7 +304,7 @@ bool setLyxPaths()
 
        // This is true when we are running from a Mac OS X bundle
        // (for LyX/Mac)
-       bool const inOSXBundle = 
+       bool const inOSXBundle =
                system_lyxdir_ == NormalizePath(AddPath(binpath, "../Resources/")
                                                + OnlyFilename(binname));
        if (inOSXBundle)
@@ -314,23 +324,23 @@ bool setLyxPaths()
                        + ":/sw/bin:/usr/local/bin"
                        + ":/usr/local/teTeX/bin/powerpc-apple-darwin-current";
                lyx::support::putenv("PATH", newpath);
-               lyxerr[Debug::INIT] << "LyX/Mac: setting PATH to: " 
+               lyxerr[Debug::INIT] << "LyX/Mac: setting PATH to: "
                                    << GetEnv("PATH") << endl;
        }
 
 
-       // 
+       //
        // Determine locale directory
        //
        if (!GetEnv("LYX_LOCALEDIR").empty()) {
                localedir_ = GetEnv("LYX_LOCALEDIR");
                lyxerr[Debug::INIT] << "LYX_LOCALEDIR=" << localedir_ << endl;
        } else if (inOSXBundle) {
-               string const maybe_localedir = 
-                       NormalizePath(AddPath(system_lyxdir_, "../locale")); 
+               string const maybe_localedir =
+                       NormalizePath(AddPath(system_lyxdir_, "../locale"));
                FileInfo fi(maybe_localedir);
                if (fi.isOK() && fi.isDir()) {
-                       lyxerr[Debug::INIT] 
+                       lyxerr[Debug::INIT]
                                << "LyX/Mac: setting locale directory to "
                                << maybe_localedir << endl;
                        localedir_ = maybe_localedir;
@@ -356,10 +366,10 @@ bool setLyxPaths()
                // default behaviour
                if (user_lyxdir_.empty())
                        if (inOSXBundle)
-                               user_lyxdir_ = AddPath(GetEnvPath("HOME"),
+                               user_lyxdir_ = AddPath(os::homepath(),
                                                       "Library/Preferences/LyX");
                        else
-                               user_lyxdir_ = AddPath(GetEnvPath("HOME"),
+                               user_lyxdir_ = AddPath(os::homepath(),
                                                       string(".") + PACKAGE);
                explicit_userdir = false;
        }