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.
This commit is contained in:
2009-07-13 18:47:08 +00:00
parent 1227d5d6d3
commit 689abe000d

View File

@@ -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;