diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-07-13 22:47:08 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-07-13 22:47:08 +0400 |
commit | 689abe000dae8a36e4afe29ad01528408ae20e8c (patch) | |
tree | 505efe049cadbc89824db76364baa21156f30465 /source/blender/blenlib | |
parent | 1227d5d6d3e96362260f3e6eeadc01612cc18898 (diff) |
2.5: bugfix for BLI_is_writable, made render with Save Buffers
not work anymore. Now it first tries to open the file without
truncating, and only then tries to create a new file.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/intern/fileops.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c index ffebd05f2f6..917537bf03d 100644 --- a/source/blender/blenlib/intern/fileops.c +++ b/source/blender/blenlib/intern/fileops.c @@ -153,10 +153,24 @@ int BLI_is_writable(char *filename) { int file; + /* first try to open without creating */ file = open(filename, O_BINARY | O_RDWR, 0666); - if (file < 0) - return 0; + if (file < 0) { + /* now try to open and create. a test without actually + * creating a file would be nice, but how? */ + file = open(filename, O_BINARY | O_RDWR | O_CREAT, 0666); + + if(file < 0) { + return 0; + } + else { + /* success, delete the file we create */ + close(file); + BLI_delete(filename, 0, 0); + return 1; + } + } else { close(file); return 1; |