[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11214] branches/soc-2007-maike/source/ blender/python/api2_2x/EXPP_interface.c: Added ugly hack to find compile tree base dir

Miguel Torres Lima torreslima at gmail.com
Tue Jul 10 20:09:46 CEST 2007


Revision: 11214
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11214
Author:   maike
Date:     2007-07-10 20:09:45 +0200 (Tue, 10 Jul 2007)

Log Message:
-----------
Added ugly hack to find compile tree base dir

Modified Paths:
--------------
    branches/soc-2007-maike/source/blender/python/api2_2x/EXPP_interface.c

Modified: branches/soc-2007-maike/source/blender/python/api2_2x/EXPP_interface.c
===================================================================
--- branches/soc-2007-maike/source/blender/python/api2_2x/EXPP_interface.c	2007-07-10 18:08:10 UTC (rev 11213)
+++ branches/soc-2007-maike/source/blender/python/api2_2x/EXPP_interface.c	2007-07-10 18:09:45 UTC (rev 11214)
@@ -50,6 +50,28 @@
  * Finally, if all else fails BLI_gethome() is returned
  * (or NULL if append_scriptdir != 0).
 */
+
+static char *bpy_getinstallhome(void)
+{
+  int len = strlen(bprogname);
+  int count = 0;
+  int i;
+  static char instdir[FILE_MAXDIR];
+
+  for(i = len - 1; i >= 0; i--){
+    if(bprogname[i] == '/' || bprogname[i] == '\\')
+      count++;
+    if(count == 4)
+      break;
+  }
+
+  if(count == 4){
+    PyOS_snprintf( instdir, i + 2, "%s", bprogname );
+    return instdir;
+  }
+  else return NULL;
+}
+
 char *bpy_gethome(int append_scriptsdir)
 {
 	static char homedir[FILE_MAXDIR];
@@ -57,6 +79,7 @@
 	char tmpdir[FILE_MAXDIR];
 	char bprogdir[FILE_MAXDIR];
 	char *s;
+	char *instdir;
 	int i;
 
 	if (append_scriptsdir) {
@@ -82,10 +105,14 @@
 
 	/* if userhome/.blender/ exists, return it */
 	if( BLI_exists( homedir ) ) {
-		if (append_scriptsdir) {
+		if (append_scriptsdir == 1) {
 			BLI_make_file_string("/", scriptsdir, homedir, "scripts");
 			if (BLI_exists (scriptsdir)) return scriptsdir;
 		}
+		else if(append_scriptsdir == 2) {
+              		BLI_make_file_string("/", scriptsdir, homedir, "glsl");
+			if (BLI_exists (scriptsdir)) return scriptsdir;
+		}
 		else return homedir;
 	}
 	else homedir[0] = '\0';
@@ -109,7 +136,7 @@
 	BLI_make_file_string( "/", tmpdir, bprogdir, ".blender" );
 
 	if (BLI_exists(tmpdir)) {
-		if (append_scriptsdir) {
+		if (append_scriptsdir == 1) {
 			BLI_make_file_string("/", scriptsdir, tmpdir, "scripts");
 			if (BLI_exists(scriptsdir)) {
 				PyOS_snprintf(homedir, FILE_MAXDIR, "%s", tmpdir);
@@ -120,19 +147,50 @@
 				scriptsdir[0] = '\0';
 			}
 		}
+		else if (append_scriptsdir == 2) {
+			BLI_make_file_string("/", scriptsdir, tmpdir, "glsl");
+			if (BLI_exists(scriptsdir)) {
+				PyOS_snprintf(homedir, FILE_MAXDIR, "%s", tmpdir);
+				return scriptsdir;
+			}
+			else {
+				homedir[0] = '\0';
+				scriptsdir[0] = '\0';
+			}
+		}
 		else return homedir;
 	}
 
 	/* last try for scripts dir: blender in cvs dir, scripts/ inside release/: */
-	if (append_scriptsdir) {
+	if (append_scriptsdir == 1) {
 		BLI_make_file_string("/", scriptsdir, bprogdir, "release/scripts");
 		if (BLI_exists(scriptsdir)) return scriptsdir;
 		else scriptsdir[0] = '\0';
 	}
-
+	else if (append_scriptsdir == 2) {
+		BLI_make_file_string("/", scriptsdir, bprogdir, "release/glsl");
+		if (BLI_exists(scriptsdir)) return scriptsdir;
+		else scriptsdir[0] = '\0';
+	}
+	
+	instdir = bpy_getinstallhome();
+	if(instdir){
+	  	if (append_scriptsdir == 1) {
+		  BLI_make_file_string("/", scriptsdir, instdir, "install/linux2/.blender/scripts");
+		  if (BLI_exists(scriptsdir)) return scriptsdir;
+		  else scriptsdir[0] = '\0';
+		}
+		else if (append_scriptsdir == 2) {
+		  BLI_make_file_string("/", scriptsdir, instdir, "install/linux2/.blender/glsl");
+		  printf("\nglsl: %s\n", scriptsdir);
+		  if (BLI_exists(scriptsdir)) return scriptsdir;
+		  else scriptsdir[0] = '\0';
+		}
+	}
 	return NULL;
 }
 
+
 /* PyDrivers */
 
 /*





More information about the Bf-blender-cvs mailing list