diff options
author | Ton Roosendaal <ton@blender.org> | 2006-06-19 17:53:00 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2006-06-19 17:53:00 +0400 |
commit | 36bedb3d7e1f5cd2ec6ccc6ecd8fb9ef30ef3f91 (patch) | |
tree | 6f4e149b4885f981288ae3785f43289250a52ec6 /source/blender/blenlib | |
parent | 03449818b3350ac46fff086f5c0096fe0d7dbf80 (diff) |
Bugfix #4363
In windows, without temp path set, the 'save buffers' render option crashes.
I've coded a blenlib BLI_is_writable(char *filename) to check for such
cases. This is not much needed in Blender, since the open() command is
checked for. However, file saving happens deep inside the C++ exr lib, and
it throws an exception crash when a file cannot be written.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_blenlib.h | 2 | ||||
-rw-r--r-- | source/blender/blenlib/intern/fileops.c | 15 |
2 files changed, 16 insertions, 1 deletions
diff --git a/source/blender/blenlib/BLI_blenlib.h b/source/blender/blenlib/BLI_blenlib.h index c920d7127ae..28fca2c29a6 100644 --- a/source/blender/blenlib/BLI_blenlib.h +++ b/source/blender/blenlib/BLI_blenlib.h @@ -256,7 +256,7 @@ int BLI_exist(char *name); void BLI_recurdir_fileops(char *dirname); int BLI_link(char *file, char *to); int BLI_backup(char *file, char *from, char *to); - +int BLI_is_writable(char *filename); /** * @attention Do not confuse with BLI_exist diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c index 9a4ffca4844..232546b89ca 100644 --- a/source/blender/blenlib/intern/fileops.c +++ b/source/blender/blenlib/intern/fileops.c @@ -125,6 +125,21 @@ int BLI_gzip(char *from, char *to) { return 0; } +/* return 1 when file can be written */ +int BLI_is_writable(char *filename) +{ + int file; + + file = open(filename, O_BINARY | O_RDWR | O_CREAT | O_TRUNC, 0666); + + if (file < 0) + return 0; + else { + close(file); + return 1; + } +} + #ifdef WIN32 static char str[MAXPATHLEN+12]; |