diff options
author | Simon Clitherow <aphex@nildram.co.uk> | 2008-04-21 19:53:32 +0400 |
---|---|---|
committer | Simon Clitherow <aphex@nildram.co.uk> | 2008-04-21 19:53:32 +0400 |
commit | 46847c8a84d417166d413bce2a43718346ebe419 (patch) | |
tree | eb4d00831c2008ccd754f80707f4cfca0de2466d /source/blender/blenlib/intern/util.c | |
parent | b8181183795ff34e8469f5aed197932b8a75807a (diff) |
Bug fix for 8634, 6708, and 5989
This replaces the hard-coded '%PROFILE%\Application Data\..." path
with the correct language-dependant CSIDL_APPDATA.
PLEASE NOTE!
Checks for the previous location have now been REMOVED. Any data
saved in the old hard-coded location will no longer be found by
Blender (this will only affect users of non-english windows.)
The installer has been updated to help the user to migrate their data
to the new location of their choice, if necessary.
Order of preference for .blender on windows is now the following:
1) %HOME% environment var
2) Installation Directory (location of blender.exe)
3) "Current User" (CSIDL_APPDATA)
4) "All Users" (CSIDL_COMMON_APPDATA)
Diffstat (limited to 'source/blender/blenlib/intern/util.c')
-rw-r--r-- | source/blender/blenlib/intern/util.c | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/source/blender/blenlib/intern/util.c b/source/blender/blenlib/intern/util.c index 88a4bb7af01..d7b9d9905fd 100644 --- a/source/blender/blenlib/intern/util.c +++ b/source/blender/blenlib/intern/util.c @@ -65,6 +65,14 @@ #endif #ifdef WIN32 + +#ifdef _WIN32_IE +#undef _WIN32_IE +#endif +#define _WIN32_IE 0x0501 +#include <windows.h> +#include <shlobj.h> + #include "BLI_winstuff.h" /* for duplicate_defgroup */ @@ -1167,6 +1175,8 @@ char *BLI_gethome(void) { #else /* Windows */ char * ret; static char dir[512]; + static char appdatapath[MAXPATHLEN]; + HRESULT hResult; /* Check for %HOME% env var */ @@ -1188,9 +1198,36 @@ char *BLI_gethome(void) { /* add user profile support for WIN 2K / NT */ + hResult = SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, appdatapath); + + if (hResult == S_OK) + { + if (BLI_exists(appdatapath)) { /* from fop, also below... */ + sprintf(dir, "%s\\Blender Foundation\\Blender", appdatapath); + BLI_recurdir_fileops(dir); + if (BLI_exists(dir)) { + strcat(dir,"\\.blender"); + if(BLI_exists(dir)) return(dir); + } + } + hResult = SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL, SHGFP_TYPE_CURRENT, appdatapath); + if (hResult == S_OK) + { + if (BLI_exists(appdatapath)) + { /* from fop, also below... */ + sprintf(dir, "%s\\Blender Foundation\\Blender", appdatapath); + BLI_recurdir_fileops(dir); + if (BLI_exists(dir)) { + strcat(dir,"\\.blender"); + if(BLI_exists(dir)) return(dir); + } + } + } + } + /* ret = getenv("USERPROFILE"); if (ret) { - if (BLI_exists(ret)) { /* from fop, also below... */ + if (BLI_exists(ret)) { /* from fop, also below... sprintf(dir, "%s\\Application Data\\Blender Foundation\\Blender", ret); BLI_recurdir_fileops(dir); if (BLI_exists(dir)) { @@ -1199,6 +1236,7 @@ char *BLI_gethome(void) { } } } + */ /* Saving in the Windows dir is less than desirable. |