diff options
-rw-r--r-- | source/blender/blenkernel/bad_level_call_stubs/stubs.c | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/blender.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/pointcache.c | 10 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_blenlib.h | 15 | ||||
-rw-r--r-- | source/blender/blenlib/intern/fileops.c | 16 | ||||
-rw-r--r-- | source/blender/blenlib/intern/util.c | 27 | ||||
-rw-r--r-- | source/blender/python/BPY_extern.h | 1 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Blender.c | 1 | ||||
-rw-r--r-- | source/blender/render/intern/source/pipeline.c | 8 | ||||
-rw-r--r-- | source/blender/src/fluidsim.c | 4 | ||||
-rw-r--r-- | source/blender/src/header_info.c | 2 | ||||
-rw-r--r-- | source/blender/src/headerbuttons.c | 2 | ||||
-rw-r--r-- | source/blender/src/space.c | 14 | ||||
-rw-r--r-- | source/blender/src/usiblender.c | 10 | ||||
-rw-r--r-- | source/creator/creator.c | 10 | ||||
-rw-r--r-- | source/gameengine/GamePlayer/ghost/GPG_ghost.cpp | 1 |
16 files changed, 94 insertions, 32 deletions
diff --git a/source/blender/blenkernel/bad_level_call_stubs/stubs.c b/source/blender/blenkernel/bad_level_call_stubs/stubs.c index 1bec1775234..e7a8fd5278d 100644 --- a/source/blender/blenkernel/bad_level_call_stubs/stubs.c +++ b/source/blender/blenkernel/bad_level_call_stubs/stubs.c @@ -49,6 +49,7 @@ int winqueue_break= 0; char bprogname[1]; +char btempdir[1]; struct IpoCurve; struct FluidsimSettings; diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 224d6af6336..8574cf00e8d 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -605,7 +605,7 @@ void BKE_write_undo(char *name) counter= counter % U.undosteps; sprintf(numstr, "%d.blend", counter); - BLI_make_file_string("/", tstr, U.tempdir, numstr); + BLI_make_file_string("/", tstr, btempdir, numstr); success= BLO_write_file(tstr, G.fileflags, &err); @@ -716,7 +716,7 @@ void BKE_undo_save_quit(void) /* no undo state to save */ if(undobase.first==undobase.last) return; - BLI_make_file_string("/", str, U.tempdir, "quit.blend"); + BLI_make_file_string("/", str, btempdir, "quit.blend"); file = open(str,O_BINARY+O_WRONLY+O_CREAT+O_TRUNC, 0666); if(file == -1) { diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 13f5cb26e94..7d3b6ca0569 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -51,9 +51,6 @@ #include "BLI_winstuff.h" #endif -/* for U.tempdir */ -#include "DNA_userdef_types.h" - /* Takes an Object ID and returns a unique name - id: object id @@ -79,9 +76,8 @@ static int ptcache_path(char *filename) return strlen(filename); } else { /* use the temp path. this is weak but better then not using point cache at all */ - if (U.tempdir[0] != '\0' && BLI_exists(U.tempdir)) { - return sprintf(filename, "%s/"PTCACHE_PATH"untitled/", U.tempdir); - } + /* btempdir is assumed to exist and ALWAYS has a trailing slash */ + return sprintf(filename, "%s"PTCACHE_PATH"untitled/", btempdir); } return -1; } @@ -100,7 +96,7 @@ int BKE_ptcache_id_filename(struct ID *id, char *filename, int cfra, int stack_i if (do_path) { len = ptcache_path(filename); if (len==-1) - return; + return -1; newname += len; } idname = (id->name+2); diff --git a/source/blender/blenlib/BLI_blenlib.h b/source/blender/blenlib/BLI_blenlib.h index 4fc4241e6dc..39b679144d5 100644 --- a/source/blender/blenlib/BLI_blenlib.h +++ b/source/blender/blenlib/BLI_blenlib.h @@ -70,7 +70,6 @@ #include "DNA_listBase.h" #include <stdlib.h> - extern ListBase fillfacebase; extern ListBase fillvertbase; /** @@ -79,6 +78,8 @@ extern ListBase fillvertbase; extern ListBase filledgebase; extern int totblock; +extern char btempdir[]; /* creator.c temp dir used instead of U.tempdir, set with BLI_where_is_temp( btempdir, 1 ); */ + struct chardesc; struct direntry; struct rctf; @@ -258,6 +259,17 @@ void BLI_free_file_lines(struct LinkNode *lines); void BLI_where_am_i(char *fullname, const char *name); /** + * Gets the temp directory when blender first runs. + * If the default path is not found, use try $TEMP + * + * Also make sure the temp dir has a trailing slash + * + * @param fullname The full path to the temp directory + */ +void BLI_where_is_temp(char *fullname, int usertemp); + + + /** * determines the full path to the application bundle on OS X * * @return path to application bundle @@ -300,6 +312,7 @@ int BLI_delete(char *file, int dir, int recursive); int BLI_move(char *file, char *to); int BLI_touch(const char *file); char *BLI_last_slash(const char *string); +void BLI_add_slash(char *string); /* BLI_rct.c */ /** diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c index 2ee42d16176..fa76f2023eb 100644 --- a/source/blender/blenlib/intern/fileops.c +++ b/source/blender/blenlib/intern/fileops.c @@ -92,6 +92,22 @@ char *BLI_last_slash(const char *string) { else return lfslash; } +/* adds a slash if there isnt one there alredy */ +void BLI_add_slash(char *string) { + int len = strlen(string); +#ifdef WIN32 + if (string[len-1]!='\\') { + string[len] = '\\'; + string[len+1] = '\0'; + } +#else + if (string[len-1]!='/') { + string[len] = '/'; + string[len+1] = '\0'; + } +#endif +} + /* gzip the file in from and write it to "to". return -1 if zlib fails, -2 if the originating file does not exist note: will remove the "from" file diff --git a/source/blender/blenlib/intern/util.c b/source/blender/blenlib/intern/util.c index d0f58a50eb9..f849b022e6e 100644 --- a/source/blender/blenlib/intern/util.c +++ b/source/blender/blenlib/intern/util.c @@ -44,8 +44,10 @@ #include "MEM_guardedalloc.h" -#include "BLI_blenlib.h" #include "DNA_listBase.h" +#include "DNA_userdef_types.h" + +#include "BLI_blenlib.h" #include "BLI_storage.h" #include "BLI_storage_types.h" #include "BLI_dynamiclist.h" @@ -1605,6 +1607,29 @@ void BLI_where_am_i(char *fullname, const char *name) } } +void BLI_where_is_temp(char *fullname, int usertemp) +{ + fullname[0] = '\0'; + + if (usertemp && BLI_exists(U.tempdir)) { + strcpy(fullname, U.tempdir); + } + + if (fullname[0] == '\0') { + char *tmp = getenv("TEMP"); + if (tmp && BLI_exists(tmp)) { + strcpy(fullname, tmp); + } + } + + if (fullname[0] == '\0') { + strcpy(fullname, "/tmp/"); + } else { + /* add a trailing slash if needed */ + BLI_add_slash(fullname); + } +} + /* * returns absolute path to the app bundle * only useful on OS X diff --git a/source/blender/python/BPY_extern.h b/source/blender/python/BPY_extern.h index e4986727ab1..28c4c2f55ff 100644 --- a/source/blender/python/BPY_extern.h +++ b/source/blender/python/BPY_extern.h @@ -34,6 +34,7 @@ #define BPY_EXTERN_H extern char bprogname[]; /* holds a copy of argv[0], from creator.c */ +extern char btempdir[]; /* use this to store a valid temp directory */ struct Text; /* defined in DNA_text_types.h */ struct ID; /* DNA_ID.h */ diff --git a/source/blender/python/api2_2x/Blender.c b/source/blender/python/api2_2x/Blender.c index 46f7b9da79f..a5a740d3b90 100644 --- a/source/blender/python/api2_2x/Blender.c +++ b/source/blender/python/api2_2x/Blender.c @@ -286,6 +286,7 @@ static PyObject *Blender_Set( PyObject * self, PyObject * args ) if ( !PyArg_Parse( arg , "s" , &dir )) return EXPP_ReturnPyObjError( PyExc_ValueError, "expected a string" ); BLI_strncpy(U.tempdir, dir, FILE_MAXDIR); + BLI_where_is_temp( btempdir, 1 ); } else if (StringEqual( name , "compressfile" ) ) { int value = PyObject_IsTrue( arg ); diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index f1e88540935..9794ed89afc 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -403,8 +403,6 @@ static int passtype_from_name(char *str) return 0; } - - static void render_unique_exr_name(Render *re, char *str, int sample) { char di[FILE_MAX], name[FILE_MAXFILE], fi[FILE_MAXFILE]; @@ -417,11 +415,7 @@ static void render_unique_exr_name(Render *re, char *str, int sample) else sprintf(name, "%s_%s%d.exr", fi, re->scene->id.name+2, sample); - if(G.background) - BLI_make_file_string("/", str, "/tmp/", name); - else - BLI_make_file_string("/", str, U.tempdir, name); - + BLI_make_file_string("/", str, btempdir, name); } static void render_layer_add_pass(RenderResult *rr, RenderLayer *rl, int channels, int passtype) diff --git a/source/blender/src/fluidsim.c b/source/blender/src/fluidsim.c index e9609d40570..a6620cef927 100644 --- a/source/blender/src/fluidsim.c +++ b/source/blender/src/fluidsim.c @@ -70,7 +70,6 @@ #include "BKE_scene.h" #include "BKE_object.h" #include "BKE_softbody.h" -#include "BKE_utildefines.h" #include "BKE_DerivedMesh.h" #include "BKE_ipo.h" #include "LBM_fluidsim.h" @@ -151,6 +150,7 @@ typedef struct { /* ********************** fluid sim settings struct functions ********************** */ /* allocates and initializes general main data */ + FluidsimSettings *fluidsimSettingsNew(struct Object *srcob) { //char blendDir[FILE_MAXDIR], blendFile[FILE_MAXFILE]; @@ -189,7 +189,7 @@ FluidsimSettings *fluidsimSettingsNew(struct Object *srcob) /* elubie: changed this to default to the same dir as the render output to prevent saving to C:\ on Windows */ - BLI_strncpy(fss->surfdataPath, U.tempdir, FILE_MAX); + BLI_strncpy(fss->surfdataPath, btempdir, FILE_MAX); fss->orgMesh = (Mesh *)srcob->data; fss->meshSurface = NULL; fss->meshBB = NULL; diff --git a/source/blender/src/header_info.c b/source/blender/src/header_info.c index 1a6e7a0b77e..08895fe941a 100644 --- a/source/blender/src/header_info.c +++ b/source/blender/src/header_info.c @@ -867,7 +867,7 @@ static void do_info_filemenu(void *arg, int event) strcpy(scestr, G.sce); /* temporal store */ save_over = G.save_over; - BLI_make_file_string("/", str, U.tempdir, "quit.blend"); + BLI_make_file_string("/", str, btempdir, "quit.blend"); retval = BKE_read_file(str, NULL); /*we successfully loaded a blend file, get sure that diff --git a/source/blender/src/headerbuttons.c b/source/blender/src/headerbuttons.c index dd3d6d9b33b..d6e0b054a8b 100644 --- a/source/blender/src/headerbuttons.c +++ b/source/blender/src/headerbuttons.c @@ -569,6 +569,8 @@ static void filesel_u_tempdir(char *name) BLI_split_dirfile(name, dir, file); strcpy(U.tempdir, dir); + BLI_where_is_temp( btempdir, 1 ); + allqueue(REDRAWALL, 0); } diff --git a/source/blender/src/space.c b/source/blender/src/space.c index e4f4d24ed23..1f450b09614 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -3340,10 +3340,18 @@ static void info_user_themebuts(uiBlock *block, short y1, short y2, short y3, sh } } +/* setting the temp dir needs to set */ +void eval_utemp_dir_callback(void *dummy1, void *dummy2) +{ + if (!BLI_exists(U.tempdir)) + error("temp directory does not exist, assign a valid directory"); + BLI_where_is_temp(btempdir, 1); +} void drawinfospace(ScrArea *sa, void *spacedata) { uiBlock *block; + uiBut *uibut; static short cur_light=0; float fac, col[3]; short xpos, ypos, ypostab, buth, rspace, dx, y1, y2, y3, y4, y5, y6, y7; @@ -4225,9 +4233,13 @@ void drawinfospace(ScrArea *sa, void *spacedata) uiBlockEndAlign(block); uiBlockBeginAlign(block); - uiDefBut(block, TEX, 0, "Temp: ", + uibut = uiDefBut(block, TEX, 0, "Temp: ", (xpos+edgsp+(3*lpref)+(3*midsp)),y1,(lpref-smfileselbut),buth, U.tempdir, 1.0, 63.0, 0, 0, "The directory for storing temporary save files"); + + /* set the btempdir from U.temp */ + uiButSetFunc(uibut, eval_utemp_dir_callback, NULL, NULL); + uiDefIconBut(block, BUT, B_TEMPDIRFILESEL, ICON_FILESEL, (xpos+edgsp+(4*lpref)+(3*midsp)-smfileselbut),y1,smfileselbut,buth, 0, 0, 0, 0, 0, "Select the default temporary save file location"); diff --git a/source/blender/src/usiblender.c b/source/blender/src/usiblender.c index 86c2d0c0f68..069dcce2375 100644 --- a/source/blender/src/usiblender.c +++ b/source/blender/src/usiblender.c @@ -177,9 +177,7 @@ static void init_userdef_file(void) } if(U.mixbufsize==0) U.mixbufsize= 2048; if (BLI_streq(U.tempdir, "/")) { - char *tmp= getenv("TEMP"); - - strcpy(U.tempdir, tmp?tmp:"/tmp/"); + BLI_where_is_temp(U.tempdir, 0); } if (U.savetime <= 0) { U.savetime = 1; @@ -646,7 +644,7 @@ static void get_autosave_location(char buf[FILE_MAXDIR+FILE_MAXFILE]) sprintf(pidstr, "%d.blend", abs(getpid())); #ifdef WIN32 - if (!BLI_exists(U.tempdir)) { + if (!BLI_exists(btempdir)) { BLI_strncpy(subdir, "autosave", sizeof(subdir)); BLI_make_file_string("/", savedir, BLI_gethome(), subdir); @@ -659,7 +657,7 @@ static void get_autosave_location(char buf[FILE_MAXDIR+FILE_MAXFILE]) } #endif - BLI_make_file_string("/", buf, U.tempdir, pidstr); + BLI_make_file_string("/", buf, btempdir, pidstr); } void BIF_read_autosavefile(void) @@ -950,7 +948,7 @@ static void delete_autosave(void) if (BLI_exists(tstr)) { char str[FILE_MAXDIR+FILE_MAXFILE]; - BLI_make_file_string("/", str, U.tempdir, "quit.blend"); + BLI_make_file_string("/", str, btempdir, "quit.blend"); if(U.uiflag & USER_GLOBALUNDO) BLI_delete(tstr, 0, 0); else BLI_rename(tstr, str); diff --git a/source/creator/creator.c b/source/creator/creator.c index 3918e29b9bf..d4a0bb49614 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -128,7 +128,7 @@ extern void winlay_process_events(int wait_for_event); extern int pluginapi_force_ref(void); /* from blenpluginapi:pluginapi.c */ char bprogname[FILE_MAXDIR+FILE_MAXFILE]; /* from blenpluginapi:pluginapi.c */ - +char btempdir[FILE_MAXDIR+FILE_MAXFILE]; /* Initialise callbacks for the modules that need them */ void setCallbacks(void); @@ -317,7 +317,7 @@ int main(int argc, char **argv) // need this. BLI_where_am_i(bprogname, argv[0]); - + /* Hack - force inclusion of the plugin api functions, * see blenpluginapi:pluginapi.c */ @@ -490,12 +490,16 @@ int main(int argc, char **argv) * added note (ton): i removed it altogether */ - BIF_init(); + BIF_init(); /* loads .B.blend */ + + BLI_where_is_temp( btempdir, 1 ); /* call after loading the .B.blend so we can read U.tempdir */ } else { BPY_start_python(argc, argv); + BLI_where_is_temp( btempdir, 0 ); /* call after loading the .B.blend so we can read U.tempdir */ + // (ton) Commented out. I have no idea whats thisfor... will mail around! // SYS_WriteCommandLineInt(syshandle,"noaudio",1); // audio = 0; diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index 23447d36401..0993446c77b 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -304,7 +304,6 @@ int main(int argc, char** argv) #endif /* __alpha__ */ #endif /* __linux__ */ BLI_where_am_i(bprogname, argv[0]); - #ifdef __APPLE__ // Can't use Carbon right now because of double defined type ID (In Carbon.h and DNA_ID.h, sigh) /* |