From 02cc8464d906298269eb68842c12705445b26b29 Mon Sep 17 00:00:00 2001 From: Oliver Duis Date: Fri, 20 Apr 2012 22:17:41 +0200 Subject: [PATCH] Fixed compilation on 32bit Windows, cleanups see issue 1333 --- rtengine/safegtk.cc | 8 +++++--- rtgui/extprog.cc | 4 ++++ rtgui/options.cc | 33 +++++++++------------------------ 3 files changed, 18 insertions(+), 27 deletions(-) diff --git a/rtengine/safegtk.cc b/rtengine/safegtk.cc index f31965c11..56e5fb218 100644 --- a/rtengine/safegtk.cc +++ b/rtengine/safegtk.cc @@ -25,6 +25,10 @@ #include #ifdef WIN32 #include +// for GCC32 +#ifndef _WIN32_IE +#define _WIN32_IE 0x0600 +#endif #include #else #include @@ -344,9 +348,7 @@ int safe_g_mkdir_with_parents(const Glib::ustring& dirName, int mode) } Glib::ustring safe_get_user_picture_dir() { - // TODO: MINGW32 has a problem with header files - #ifdef __MINGW64_VERSION_MAJOR - + #ifdef WIN32 // get_user_special_dir/pictures crashes on some Windows configurations. // so we use the safe native functions here WCHAR pathW[MAX_PATH]={0}; diff --git a/rtgui/extprog.cc b/rtgui/extprog.cc index 12b0e8449..96469f9c6 100644 --- a/rtgui/extprog.cc +++ b/rtgui/extprog.cc @@ -23,6 +23,10 @@ #include "../rtengine/safegtk.h" #ifdef WIN32 #include +// for GCC32 +#ifndef _WIN32_IE +#define _WIN32_IE 0x0600 +#endif #include #endif using namespace std; diff --git a/rtgui/options.cc b/rtgui/options.cc index d530c6936..d9784bb8c 100644 --- a/rtgui/options.cc +++ b/rtgui/options.cc @@ -29,6 +29,10 @@ #ifdef WIN32 #include +// for GCC32 +#ifndef _WIN32_IE +#define _WIN32_IE 0x0600 +#endif #include #endif @@ -753,37 +757,18 @@ void Options::load () { // Find the application data path #ifdef WIN32 - /* - * If LOCALAPPDATA exists, RT run on a WinVista/7 system, so we use LOCALAPPDATA as is - * otherwise RT run on a Win2000/XP system, so we rebuild the path like this: %USERPROFILE%\Local Settings\Application Data - * - * Folder redirection is then fully supported on WinVista/7, but not on Win2000/XP - */ const gchar* dataPath; Glib::ustring dPath; - // ->ODUIS: How to make that commented out code work ? - - /*WCHAR path[MAX_PATH] = {0}; - if (SHGetSpecialFolderPathW(NULL, path, CSIDL_LOCAL_APPDATA, false)) { - dPath = path; - printf("SHGetSpecialFolderPathW: \"%s\"\n", dPath.c_str()); - } - else { - printf("SHGetSpecialFolderPathW: Fail!\n"); - }*/ - dataPath = g_getenv("RT_CACHE"); if (dataPath != NULL) rtdir = Glib::ustring(dataPath); else { - dataPath = g_getenv("LOCALAPPDATA"); - if (dataPath != NULL) - rtdir = Glib::ustring(dataPath) + Glib::ustring("\\") + Glib::ustring(CACHEFOLDERNAME); - else { - dataPath = g_getenv("USERPROFILE"); - if (dataPath != NULL) - rtdir = Glib::ustring(dataPath) + Glib::ustring("\\Local Settings\\Application Data\\") + Glib::ustring(CACHEFOLDERNAME); + WCHAR pathW[MAX_PATH]={0}; char pathA[MAX_PATH]; + + if (SHGetSpecialFolderPathW(NULL,pathW,CSIDL_LOCAL_APPDATA,false)) { + WideCharToMultiByte(CP_UTF8,0,pathW,-1,pathA,MAX_PATH,0,0); + rtdir = Glib::ustring(pathA) + Glib::ustring("\\") + Glib::ustring(CACHEFOLDERNAME); } } #else