diff options
author | Andrea Weikert <elubie@gmx.net> | 2006-03-19 16:28:01 +0300 |
---|---|---|
committer | Andrea Weikert <elubie@gmx.net> | 2006-03-19 16:28:01 +0300 |
commit | 368cab399c0d7fac73929a79ee829812d9463a8f (patch) | |
tree | 0e5ac2b4445e0c4889ddff1ffd3bcfc643d56e74 /source/blender/blenlib/intern/storage.c | |
parent | 59ed566e86eaa7514101777910ac99fb2fdd3c2d (diff) |
=== bugfix win32 - python ===
Fixed BLI_exist: In Windows stat doesn't recognize
a dirname ending is a slash, exept when it's
the root dir ("C:\\"), where it is required.
So trailing slashes are only removed when filename
is longer than 3 chars.
Also fixed Python Sys.c that now uses BLI_exist
instead of calling stat directly.
Diffstat (limited to 'source/blender/blenlib/intern/storage.c')
-rw-r--r-- | source/blender/blenlib/intern/storage.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c index 8b45bfe0420..0487154f7df 100644 --- a/source/blender/blenlib/intern/storage.c +++ b/source/blender/blenlib/intern/storage.c @@ -104,6 +104,8 @@ struct statfs { #include "BLI_util.h" #include "BLI_linklist.h" +#include "BKE_utildefines.h" + /* vars: */ static int totnum,actnum; static struct direntry *files; @@ -459,8 +461,19 @@ int BLI_filesize(int file) int BLI_exist(char *name) { struct stat st; - - if (stat(name,&st)) return(0); +#ifdef WIN32 + /* in Windows stat doesn't recognize dir ending on a slash + To not break code where the ending slash is expected we + don't mess with the argument name directly here - elubie */ + char tmp[FILE_MAXDIR+FILE_MAXFILE]; + int len; + BLI_strncpy(tmp, name, FILE_MAXDIR+FILE_MAXFILE); + len = strlen(tmp); + if (len > 3 && ( tmp[len-1]=='\\' || tmp[len-1]=='/') ) tmp[len-1] = '\0'; + if (stat(tmp,&st)) return(0); +#else + if (stat(name,&st)) return(0); +#endif return(st.st_mode); } |