diff options
author | Andrea Weikert <elubie@gmx.net> | 2007-02-28 23:11:10 +0300 |
---|---|---|
committer | Andrea Weikert <elubie@gmx.net> | 2007-02-28 23:11:10 +0300 |
commit | e53c5058b4cb386c6b3f63cec52750c2f6a1021b (patch) | |
tree | bdf7ec7990082c07b138c92bc2e8125a772c5c56 /source/blender/blenlib | |
parent | b58d1f9ba05c56310a1067b25d502b84c7cd0021 (diff) |
=== bugfix ===
filename and path issues:
[ #6107 ] Animation crashes when ouput folder does not exist
- using the Windows drive as default and only then degrading to the
Blender installation drive and then the first valid drive.
- in case of degrading added error message print to console to make it
transparent
[ #6106 ] fluids - no default path
- setting the default path to U.tempdir where Blender stores temporary files
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/intern/util.c | 2 | ||||
-rw-r--r-- | source/blender/blenlib/intern/winstuff.c | 60 |
2 files changed, 44 insertions, 18 deletions
diff --git a/source/blender/blenlib/intern/util.c b/source/blender/blenlib/intern/util.c index 8de2970119f..ab57b50516f 100644 --- a/source/blender/blenlib/intern/util.c +++ b/source/blender/blenlib/intern/util.c @@ -1014,7 +1014,7 @@ void BLI_make_exist(char *dir) { } if (a >= 0) dir[a+1] = 0; else { - /* defaulting to first valid drive hoping it's not empty CD and DVD drives */ + /* defaulting to drive (usually 'C:') of Windows installation */ get_default_root(dir); break; } diff --git a/source/blender/blenlib/intern/winstuff.c b/source/blender/blenlib/intern/winstuff.c index 6b861ad43df..1a3dfa79516 100644 --- a/source/blender/blenlib/intern/winstuff.c +++ b/source/blender/blenlib/intern/winstuff.c @@ -150,27 +150,53 @@ int closedir (DIR *dp) { } void get_default_root(char* root) { - DWORD tmp; - int i; - - tmp= GetLogicalDrives(); - - for (i=2; i < 26; i++) { - if ((tmp>>i) & 1) { - root[0] = 'a'+i; + char str[MAX_PATH+1]; + + /* the default drive to resolve a directory without a specified drive + should be the Windows installation drive, since this was what the OS + assumes. */ + if (GetWindowsDirectory(str,MAX_PATH+1)) { + root[0] = str[0]; + root[1] = ':'; + root[2] = '\\'; + root[3] = '\0'; + } else { + /* if GetWindowsDirectory fails, something has probably gone wrong, + we are trying the blender install dir though */ + if (GetModuleFileName(NULL,str,MAX_PATH+1)) { + printf("Error! Could not get the Windows Directory - Defaulting to Blender installation Dir!"); + root[0] = str[0]; root[1] = ':'; root[2] = '\\'; root[3] = '\0'; - if (GetFileAttributes(root) != 0xFFFFFFFF) - return; - } + } else { + DWORD tmp; + int i; + int rc = 0; + /* now something has gone really wrong - still trying our best guess */ + printf("Error! Could not get the Windows Directory - Defaulting to first valid drive! Path might be invalid!"); + tmp= GetLogicalDrives(); + for (i=2; i < 26; i++) { + if ((tmp>>i) & 1) { + root[0] = 'a'+i; + root[1] = ':'; + root[2] = '\\'; + root[3] = '\0'; + if (GetFileAttributes(root) != 0xFFFFFFFF) { + rc = i; + break; + } + } + } + if (0 == rc) { + printf("ERROR in 'get_default_root': can't find a valid drive!"); + root[0] = 'C'; + root[1] = ':'; + root[2] = '\\'; + root[3] = '\0'; + } + } } - - printf("ERROR in 'get_default_root': can't find a valid drive!"); - root[0] = 'c'; - root[1] = ':'; - root[2] = '\\'; - root[3] = '\0'; } #else |