Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-07-13 22:47:08 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-07-13 22:47:08 +0400
commit689abe000dae8a36e4afe29ad01528408ae20e8c (patch)
tree505efe049cadbc89824db76364baa21156f30465 /source/blender/blenlib/intern/fileops.c
parent1227d5d6d3e96362260f3e6eeadc01612cc18898 (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/intern/fileops.c')
-rw-r--r--source/blender/blenlib/intern/fileops.c18
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;