From dcbfa25bc8903fbffb563c6e0f5c89d94ea27ed3 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 13 Mar 2013 19:48:07 +0000 Subject: Fix #34551: blender crash rendering with save buffers. Problem was the new usage of access() on Windows, this doesn't accept X_OK. Also wrapped _waccess so that UTF-8 paths work. --- source/blender/blenlib/BLI_fileops.h | 1 + source/blender/blenlib/BLI_winstuff.h | 3 ++- source/blender/blenlib/intern/fileops.c | 20 ++++++++++++++++++-- 3 files changed, 21 insertions(+), 3 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenlib/BLI_fileops.h b/source/blender/blenlib/BLI_fileops.h index 217afb1ca21..b0e3f47b627 100644 --- a/source/blender/blenlib/BLI_fileops.h +++ b/source/blender/blenlib/BLI_fileops.h @@ -73,6 +73,7 @@ void BLI_free_filelist(struct direntry * filelist, unsigned int nrentries); FILE *BLI_fopen(const char *filename, const char *mode); void *BLI_gzopen(const char *filename, const char *mode); int BLI_open(const char *filename, int oflag, int pmode); +int BLI_access(const char *filename, int mode); bool BLI_file_is_writable(const char *file); bool BLI_file_touch(const char *file); diff --git a/source/blender/blenlib/BLI_winstuff.h b/source/blender/blenlib/BLI_winstuff.h index fe538fcb42a..20a4c3c274e 100644 --- a/source/blender/blenlib/BLI_winstuff.h +++ b/source/blender/blenlib/BLI_winstuff.h @@ -97,7 +97,8 @@ extern "C" { #ifdef _MSC_VER # define R_OK 4 # define W_OK 2 -# define X_OK 1 +// not accepted by access() on windows +//# define X_OK 1 # define F_OK 0 # define PATH_MAX 4096 #endif diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c index bda67e2eb74..29280c36222 100644 --- a/source/blender/blenlib/intern/fileops.c +++ b/source/blender/blenlib/intern/fileops.c @@ -167,7 +167,7 @@ char *BLI_file_ungzip_to_mem(const char *from_file, int *size_r) bool BLI_file_is_writable(const char *filename) { bool writable; - if (access(filename, W_OK) == 0) { + if (BLI_access(filename, W_OK) == 0) { /* file exists and I can write to it */ writable = true; } @@ -179,7 +179,12 @@ bool BLI_file_is_writable(const char *filename) /* file doesn't exist -- check I can create it in parent directory */ char parent[FILE_MAX]; BLI_split_dirfile(filename, parent, NULL, sizeof(parent), 0); - writable = access(parent, X_OK | W_OK) == 0; +#ifdef WIN32 + /* windows does not have X_OK */ + writable = BLI_access(parent, W_OK) == 0; +#else + writable = BLI_access(parent, X_OK | W_OK) == 0; +#endif } return writable; } @@ -258,6 +263,11 @@ int BLI_open(const char *filename, int oflag, int pmode) return uopen(filename, oflag, pmode); } +int BLI_access(const char *filename, int mode) +{ + return uaccess(filename, mode); +} + int BLI_delete(const char *file, bool dir, bool recursive) { int err; @@ -597,6 +607,12 @@ int BLI_open(const char *filename, int oflag, int pmode) return open(filename, oflag, pmode); } +int BLI_access(const char *filename, int mode) +{ + return access(filename, mode); +} + + /** * Deletes the specified file or directory (depending on dir), optionally * doing recursive delete of directory contents. -- cgit v1.2.3