]> git.lyx.org Git - lyx.git/blobdiff - development/Win32/package.C
Check if we are on column 0 for special case
[lyx.git] / development / Win32 / package.C
index c7819007e168289b227c8e2b866698ea73cd6a14..fd92e5cea260f8c230fc94e706649ac41bb166ca 100644 (file)
@@ -19,6 +19,7 @@
 #include "debug.h"
 #include "gettext.h"
 
+#include "support/environment.h"
 #include "support/filetools.h"
 #include "support/lstrings.h"
 #include "support/os.h"
 #endif
 
 #if defined (USE_WINDOWS_PACKAGING)
+
+/*
+ * MinGW's version of winver.h contains this comment:
+ *
+ * If you need Win32 API features newer the Win95 and WinNT then you must
+ * define WINVER before including windows.h or any other method of including
+ * the windef.h header.
+ *
+ * GetLongPathNameA requires WINVER == 0x0500.
+ *
+ * It doesn't matter if the Windows version is older than this because the
+ * function will compile but will fail at run time. See
+ * http://msdn.microsoft.com/library/en-us/mslu/winprog/microsoft_layer_for_unicode_apis_with_limited_support.asp
+ */
+# if defined(__MINGW32__)
+#  define WINVER 0x0500
+# endif
+
 # include <windows.h>
 # include <shlobj.h>  // SHGetFolderPath
 
@@ -182,7 +201,7 @@ string const hardcoded_localedir()
 
 string const hardcoded_system_support_dir()
 {
-       return string("%LYX_DIR%");
+       return string("../../lib/");
 }
 
 } // namespace anon
@@ -319,9 +338,9 @@ string const get_document_dir(string const & home_dir)
 string const get_home_dir()
 {
 #if defined (USE_WINDOWS_PACKAGING)
-       string const home_dir = GetEnv("USERPROFILE");
+       string const home_dir = getEnv("USERPROFILE");
 #else // Posix-like.
-       string const home_dir = GetEnv("HOME");
+       string const home_dir = getEnv("HOME");
 #endif
 
        return os::internal_path(home_dir);
@@ -362,6 +381,7 @@ string const get_temp_dir()
        // Typical example: C:/TEMP/.
        char path[MAX_PATH + 1];
        GetTempPath(MAX_PATH, path);
+       GetLongPathName(path, path, MAX_PATH + 1);
        return os::internal_path(path);
 #else // Posix-like.
        return "/tmp";
@@ -394,7 +414,12 @@ string const abs_path_from_command_line(string const & command_line)
 // Does the grunt work for abs_path_from_binary_name()
 string const get_binary_path(string const & exe)
 {
-       string const exe_path = os::internal_path(exe);
+       // The executable may have been invoked either with or
+       // without the .exe extension.
+       // Ensure that it is present.
+       string const as_internal_path = os::internal_path(exe);
+       string const exe_path = suffixIs(as_internal_path, ".exe") ?
+               as_internal_path : as_internal_path + ".exe";
        if (os::is_absolute_path(exe_path))
                return exe_path;
 
@@ -650,7 +675,7 @@ bool check_command_line_dir(string const & dir,
 // The environment variable @c env_var expands to a (single) file path.
 string const extract_env_var_dir(string const & env_var)
 {
-       string const dir = os::internal_path(GetEnv(env_var));
+       string const dir = os::internal_path(getEnv(env_var));
        return dir.empty() ? dir : MakeAbsPath(dir);
 }