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.
This commit is contained in:
Brecht Van Lommel
2013-03-13 19:48:07 +00:00
parent 962865d19f
commit dcbfa25bc8
5 changed files with 36 additions and 3 deletions

View File

@@ -75,6 +75,20 @@ int uopen(const char *filename, int oflag, int pmode)
return f;
}
int uaccess(const char *filename, int mode)
{
int r = -1;
UTF16_ENCODE(filename);
if (filename_16) {
r = _waccess(filename_16, mode);
}
UTF16_UN_ENCODE(filename);
return r;
}
int urename(const char *oldname, const char *newname )
{
int r = -1;

View File

@@ -32,6 +32,7 @@
FILE * ufopen(const char * filename, const char * mode);
int uopen(const char *filename, int oflag, int pmode);
int uaccess(const char *filename, int mode);
int urename(const char *oldname, const char *newname );
char * u_alloc_getenv(const char *varname);

View File

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

View File

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

View File

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