[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30399] trunk/blender/source/blender: == installation paths ==

Andrea Weikert elubie at gmx.net
Thu Jul 15 23:39:47 CEST 2010


Revision: 30399
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30399
Author:   elubie
Date:     2010-07-15 23:39:47 +0200 (Thu, 15 Jul 2010)

Log Message:
-----------
== 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.

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/BLI_path_util.h
    trunk/blender/source/blender/blenlib/intern/path_util.c
    trunk/blender/source/blender/python/intern/bpy_app.c
    trunk/blender/source/blender/windowmanager/intern/wm_files.c
    trunk/blender/source/blender/windowmanager/intern/wm_init_exit.c

Modified: trunk/blender/source/blender/blenlib/BLI_path_util.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_path_util.h	2010-07-15 21:05:11 UTC (rev 30398)
+++ trunk/blender/source/blender/blenlib/BLI_path_util.h	2010-07-15 21:39:47 UTC (rev 30399)
@@ -59,6 +59,7 @@
 #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 */

Modified: trunk/blender/source/blender/blenlib/intern/path_util.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/path_util.c	2010-07-15 21:05:11 UTC (rev 30398)
+++ trunk/blender/source/blender/blenlib/intern/path_util.c	2010-07-15 21:39:47 UTC (rev 30399)
@@ -732,66 +732,38 @@
 	}
 }
 
+/* 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 @@
 			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,17 +1012,17 @@
 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]) {
 		return NULL;
@@ -1058,7 +1035,7 @@
 	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);

Modified: trunk/blender/source/blender/python/intern/bpy_app.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_app.c	2010-07-15 21:05:11 UTC (rev 30398)
+++ trunk/blender/source/blender/python/intern/bpy_app.c	2010-07-15 21:39:47 UTC (rev 30399)
@@ -43,7 +43,6 @@
 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 @@
 
 	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));

Modified: trunk/blender/source/blender/windowmanager/intern/wm_files.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_files.c	2010-07-15 21:05:11 UTC (rev 30398)
+++ trunk/blender/source/blender/windowmanager/intern/wm_files.c	2010-07-15 21:39:47 UTC (rev 30399)
@@ -434,9 +434,6 @@
 			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 @@
 {
 	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;
 	}

Modified: trunk/blender/source/blender/windowmanager/intern/wm_init_exit.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_init_exit.c	2010-07-15 21:05:11 UTC (rev 30398)
+++ trunk/blender/source/blender/windowmanager/intern/wm_init_exit.c	2010-07-15 21:39:47 UTC (rev 30399)
@@ -164,6 +164,10 @@
 	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);
 
 }





More information about the Bf-blender-cvs mailing list