#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
// 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";
// 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;