Index: source/blender/blenkernel/intern/blender.c =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/blenkernel/intern/blender.c,v retrieving revision 1.47 diff -u -r1.47 blender.c --- source/blender/blenkernel/intern/blender.c 27 Nov 2006 10:43:00 -0000 1.47 +++ source/blender/blenkernel/intern/blender.c 1 Dec 2006 10:22:46 -0000 @@ -36,8 +36,10 @@ #ifndef WIN32 #include // for read close #include // for MAXPATHLEN + #include //for startup py directory #else #include // for open close read + #include "BLI_winstuff.h" //for startup py directory #endif #include @@ -434,6 +436,50 @@ 2: OK, and with new user settings */ +char *get_load_pystartup_dir (){ + static char startupdir[FILE_MAXDIR]; + static char scriptsdir[FILE_MAXDIR]; + static char homedir[FILE_MAXDIR]; + char *s; + s = BLI_gethome(); + if( !s ) + return NULL; + if( strstr( s, ".blender" ) ) + PyOS_snprintf( homedir, FILE_MAXDIR, s ); + else + BLI_make_file_string( "/", homedir, s, ".blender" ); + if( BLI_exists( homedir ) ) { + BLI_make_file_string("/", scriptsdir, homedir, "scripts"); + if (BLI_exists (scriptsdir)) { + BLI_make_file_string("/", startupdir, scriptsdir, "startup"); + if (BLI_exists (startupdir)) return startupdir; + else return NULL; + } else return NULL;; + } else return NULL; +} + +void read_startup_py() +{ + char *sdir = NULL; + sdir=get_load_pystartup_dir(); + DIR *dir; + struct dirent *de; + char path[FILE_MAXDIR]; + if (!sdir) return; + dir = opendir(sdir); + if (dir != NULL) { + while ((de = readdir(dir)) != NULL) { + if ((de->d_name[0] == '.') || !strncmp(de->d_name, "py", 2)) { + continue; + } + BLI_make_file_string("/", path, sdir, de->d_name); + printf("Loading %s\n",path); + BPY_run_python_script (path); + } + closedir(dir); + } +} + int BKE_read_file(char *dir, void *type_r) { BlendReadError bre; @@ -460,6 +506,8 @@ if (!G.background) waitcursor(0); + read_startup_py(); + return (bfd?retval:0); } @@ -483,6 +531,8 @@ if (!G.background) waitcursor(0); + + read_startup_py(); return (bfd?1:0); }