diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2014-11-06 15:08:43 +0300 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2014-11-06 15:08:43 +0300 |
commit | 70f74daa5a57692cfce67999734a1b925d894ec5 (patch) | |
tree | c41d0cabf2b59af631200f38f5a718205a426863 | |
parent | ba872f022cd40d3ff9f2314830dcac5204a6c506 (diff) |
Slight corrections to the string formatting of autosave, thanks to
Campbell for the help!
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index f1e9f30dac5..d6568ea9c15 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -1068,17 +1068,20 @@ int wm_userpref_write_exec(bContext *C, wmOperator *op) void wm_autosave_location(char *filepath) { - char pidstr[32]; + const int pid = abs(getpid()); char path[1024]; #ifdef WIN32 const char *savedir; #endif - BLI_snprintf(pidstr, sizeof(pidstr), "%d", abs(getpid())); - if (G.main) - BLI_snprintf(path, sizeof(path), "%s-%s", pidstr, BLI_path_basename(G.main->name)); - else - BLI_snprintf(path, sizeof(path), "%s.blend", pidstr); + if (G.main && G.relbase_valid) { + const char *basename = BLI_path_basename(G.main->name); + int len = strlen(basename) - 6; + BLI_snprintf(path, sizeof(path), "%.*s-%d.blend", len, basename, pid); + } + else { + BLI_snprintf(path, sizeof(path), "%d.blend", pid); + } #ifdef WIN32 /* XXX Need to investigate how to handle default location of '/tmp/' |