]> git.lyx.org Git - lyx.git/blobdiff - development/Win32/package.C
Fix some WorkArea fallouts
[lyx.git] / development / Win32 / package.C
index 76b8b0953444a768f9866767fb70e3e08929dd0a..fd92e5cea260f8c230fc94e706649ac41bb166ca 100644 (file)
 #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
 
@@ -363,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";
@@ -395,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;