diff options
author | Andrea Weikert <elubie@gmx.net> | 2010-07-16 01:39:47 +0400 |
---|---|---|
committer | Andrea Weikert <elubie@gmx.net> | 2010-07-16 01:39:47 +0400 |
commit | 615db01b01c4ad96d8e712aa5469d9eb3ada0d07 (patch) | |
tree | 3a067eb23e558931a7910eccac0070912ddf6dbf | |
parent | 2f96ac8b9ff6290e2a63546cdab168e4376f3128 (diff) |
== installation paths ==
* fix for autosave location -> shouldn't use BLI_gethome anymore
* this frees BLI_gethome of having to emulate the local->user->system search path and can now be truly considered as 'home/default location for .blend files'
* removed setting the default G.sce from read_history, was out of context there.
* fix for creating user dir, leftover from previous commit.
jesterKing, please review -> if there are any issues I will fix or revert.
-rw-r--r-- | source/blender/blenlib/BLI_path_util.h | 1 | ||||
-rw-r--r-- | source/blender/blenlib/intern/path_util.c | 61 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_app.c | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 14 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_init_exit.c | 4 |
5 files changed, 26 insertions, 56 deletions
diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h index 57e6d0b16d7..60d35c9ecdf 100644 --- a/source/blender/blenlib/BLI_path_util.h +++ b/source/blender/blenlib/BLI_path_util.h @@ -59,6 +59,7 @@ char *BLI_get_folder_create(int folder_id, char *subfolder); #define BLENDER_USER_DATAFILES 32 #define BLENDER_USER_SCRIPTS 33 #define BLENDER_USER_PLUGINS 34 +#define BLENDER_USER_AUTOSAVE 35 /* system */ #define BLENDER_SYSTEM_CONFIG 51 /* optional */ diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index 6ab7ba2a7a5..df1e2c7d590 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -732,66 +732,38 @@ void BLI_getlastdir(const char* dir, char *last, int maxlen) } } +/* This is now only used to really get the user's home folder */ +/* On Windows I chose the 'Users/<MyUserName>/Documents' since it's used + as default location to save documents */ char *BLI_gethome(void) { #if !defined(WIN32) return getenv("HOME"); #else /* Windows */ char * ret; - static char dir[512]; - static char appdatapath[MAXPATHLEN]; + static char documentfolder[MAXPATHLEN]; HRESULT hResult; /* Check for %HOME% env var */ ret = getenv("HOME"); if(ret) { - sprintf(dir, "%s\\%s", ret, blender_version_decimal()); - if (BLI_is_dir(dir)) return dir; + if (BLI_is_dir(ret)) return ret; } - - /* else, check install dir (path containing blender.exe) */ - - if(BLI_getInstallationDir(dir)) - { - sprintf(dir, "%s", dir, blender_version_decimal()); - if (BLI_is_dir(dir)) return(dir); - } - /* add user profile support for WIN 2K / NT. * This is %APPDATA%, which translates to either * %USERPROFILE%\Application Data or since Vista * to %USERPROFILE%\AppData\Roaming */ - hResult = SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, appdatapath); + hResult = SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, documentfolder); if (hResult == S_OK) { - if (BLI_is_dir(appdatapath)) { /* from fop, also below... */ - sprintf(dir, "%s\\Blender Foundation\\Blender", appdatapath); - BLI_recurdir_fileops(dir); - if (BLI_is_dir(dir)) { - sprintf(dir,"%s\\%s", dir, blender_version_decimal()); - if(BLI_is_dir(dir)) return(dir); - } - } - hResult = SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL, SHGFP_TYPE_CURRENT, appdatapath); - if (hResult == S_OK) - { - if (BLI_is_dir(appdatapath)) - { /* from fop, also below... */ - sprintf(dir, "%s\\Blender Foundation\\Blender", appdatapath); - BLI_recurdir_fileops(dir); - if (BLI_is_dir(dir)) { - sprintf(dir,"%s\\%s", dir, blender_version_decimal()); - if(BLI_is_dir(dir)) return(dir); - } - } - } + if (BLI_is_dir(documentfolder)) return documentfolder; } - return "C:\\Temp"; /* sheesh! bad, bad, bad! (aphex) */ + return NULL; #endif } @@ -989,6 +961,11 @@ char *BLI_get_folder(int folder_id, char *subfolder) if (get_path_system(path, "datafiles", subfolder, "BLENDER_SYSTEM_DATAFILES")) break; return NULL; + case BLENDER_USER_AUTOSAVE: + if (get_path_local(path, "autosave", subfolder)) break; + if (get_path_user(path, "autosave", subfolder, "BLENDER_USER_DATAFILES")) break; + return NULL; + case BLENDER_CONFIG: /* general case */ if (get_path_local(path, "config", subfolder)) break; if (get_path_user(path, "config", subfolder, "BLENDER_USER_CONFIG")) break; @@ -1035,16 +1012,16 @@ char *BLI_get_folder(int folder_id, char *subfolder) static char *BLI_get_user_folder_notest(int folder_id, char *subfolder) { static char path[FILE_MAX] = ""; - char search_path[FILE_MAX]; switch (folder_id) { case BLENDER_USER_DATAFILES: - BLI_join_dirfile(search_path, "datafiles", subfolder); - get_path_user(path, search_path, subfolder, "BLENDER_USER_DATAFILES"); + get_path_user(path, "datafiles", subfolder, "BLENDER_USER_DATAFILES"); break; case BLENDER_USER_CONFIG: - BLI_join_dirfile(search_path, "config", subfolder); - get_path_user(path, search_path, subfolder, "BLENDER_USER_CONFIG"); + get_path_user(path, "config", subfolder, "BLENDER_USER_CONFIG"); + break; + case BLENDER_USER_AUTOSAVE: + get_path_user(path, "autosave", subfolder, "BLENDER_USER_AUTOSAVE"); break; } if ('\0' == path[0]) { @@ -1058,7 +1035,7 @@ char *BLI_get_folder_create(int folder_id, char *subfolder) char *path; /* only for user folders */ - if (!ELEM(folder_id, BLENDER_USER_DATAFILES, BLENDER_USER_CONFIG)) + if (!ELEM3(folder_id, BLENDER_USER_DATAFILES, BLENDER_USER_CONFIG, BLENDER_USER_AUTOSAVE)) return NULL; path = BLI_get_folder(folder_id, subfolder); diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c index 4a2ac0c9252..78658a611a3 100644 --- a/source/blender/python/intern/bpy_app.c +++ b/source/blender/python/intern/bpy_app.c @@ -43,7 +43,6 @@ static PyTypeObject BlenderAppType; static PyStructSequence_Field app_info_fields[] = { {"version", "The Blender version as a tuple of 3 numbers. eg. (2, 50, 11)"}, {"version_string", "The Blender version formatted as a string"}, - {"home", "The blender home directory, normally matching $HOME"}, {"binary_path", "The location of blenders executable, useful for utilities that spawn new instances"}, {"debug", "Boolean, set when blender is running in debug mode (started with -d)"}, {"background", "Boolean, True when blender is running without a user interface (started with -b)"}, @@ -85,7 +84,6 @@ static PyObject *make_app_info(void) SetObjItem(Py_BuildValue("(iii)", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION)); SetObjItem(PyUnicode_FromFormat("%d.%02d (sub %d)", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION)); - SetStrItem(BLI_gethome()); SetStrItem(bprogname); SetObjItem(PyBool_FromLong(G.f & G_DEBUG)); SetObjItem(PyBool_FromLong(G.background)); diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index ff859ebe166..89b8267bb05 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -434,9 +434,6 @@ void read_history(void) num++; } } - - if(G.sce[0] == 0) - BLI_make_file_string("/", G.sce, BLI_gethome(), "untitled.blend"); BLI_free_file_lines(lines); @@ -686,21 +683,14 @@ void wm_autosave_location(char *filename) { char pidstr[32]; #ifdef WIN32 - char subdir[9]; - char savedir[FILE_MAXDIR]; + char *savedir; #endif sprintf(pidstr, "%d.blend", abs(getpid())); #ifdef WIN32 if (!BLI_exists(U.tempdir)) { - BLI_strncpy(subdir, "autosave", sizeof(subdir)); - BLI_make_file_string("/", savedir, BLI_gethome(), subdir); - - /* create a new autosave dir - * function already checks for existence or not */ - BLI_recurdir_fileops(savedir); - + savedir = BLI_get_folder_create(BLENDER_USER_AUTOSAVE, NULL); BLI_make_file_string("/", filename, savedir, pidstr); return; } diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index db668390b88..5bfaf91aa11 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -164,6 +164,10 @@ void WM_init(bContext *C, int argc, char **argv) G.ndofdevice = -1; /* XXX bad initializer, needs set otherwise buttons show! */ read_history(); + + if(G.sce[0] == 0) + BLI_make_file_string("/", G.sce, BLI_gethome(), "untitled.blend"); + BLI_strncpy(G.lib, G.sce, FILE_MAX); } |