[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [55253] trunk/blender: Fix #34551: blender crash rendering with save buffers.

Brecht Van Lommel brechtvanlommel at pandora.be
Wed Mar 13 20:48:07 CET 2013


Revision: 55253
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=55253
Author:   blendix
Date:     2013-03-13 19:48:07 +0000 (Wed, 13 Mar 2013)
Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/intern/utfconv/utf_winfunc.c
    trunk/blender/intern/utfconv/utf_winfunc.h
    trunk/blender/source/blender/blenlib/BLI_fileops.h
    trunk/blender/source/blender/blenlib/BLI_winstuff.h
    trunk/blender/source/blender/blenlib/intern/fileops.c

Modified: trunk/blender/intern/utfconv/utf_winfunc.c
===================================================================
--- trunk/blender/intern/utfconv/utf_winfunc.c	2013-03-13 18:10:05 UTC (rev 55252)
+++ trunk/blender/intern/utfconv/utf_winfunc.c	2013-03-13 19:48:07 UTC (rev 55253)
@@ -75,6 +75,20 @@
 	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;

Modified: trunk/blender/intern/utfconv/utf_winfunc.h
===================================================================
--- trunk/blender/intern/utfconv/utf_winfunc.h	2013-03-13 18:10:05 UTC (rev 55252)
+++ trunk/blender/intern/utfconv/utf_winfunc.h	2013-03-13 19:48:07 UTC (rev 55253)
@@ -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);

Modified: trunk/blender/source/blender/blenlib/BLI_fileops.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_fileops.h	2013-03-13 18:10:05 UTC (rev 55252)
+++ trunk/blender/source/blender/blenlib/BLI_fileops.h	2013-03-13 19:48:07 UTC (rev 55253)
@@ -73,6 +73,7 @@
 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);

Modified: trunk/blender/source/blender/blenlib/BLI_winstuff.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_winstuff.h	2013-03-13 18:10:05 UTC (rev 55252)
+++ trunk/blender/source/blender/blenlib/BLI_winstuff.h	2013-03-13 19:48:07 UTC (rev 55253)
@@ -97,7 +97,8 @@
 #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

Modified: trunk/blender/source/blender/blenlib/intern/fileops.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/fileops.c	2013-03-13 18:10:05 UTC (rev 55252)
+++ trunk/blender/source/blender/blenlib/intern/fileops.c	2013-03-13 19:48:07 UTC (rev 55253)
@@ -167,7 +167,7 @@
 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 @@
 		/* 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 @@
 	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 @@
 	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.




More information about the Bf-blender-cvs mailing list