[Bf-blender-cvs] [28c34d3] master: Assert when relative paths are passed to IO ops

Campbell Barton noreply at git.blender.org
Thu Jun 18 04:53:52 CEST 2015


Commit: 28c34d332f941259de6775af57758609ee7c92e9
Author: Campbell Barton
Date:   Thu Jun 18 12:37:24 2015 +1000
Branches: master
https://developer.blender.org/rB28c34d332f941259de6775af57758609ee7c92e9

Assert when relative paths are passed to IO ops

This is typically an error (& hangs a few seconds on win32), best catch early.

===================================================================

M	source/blender/blenlib/intern/fileops.c
M	source/blender/blenlib/intern/storage.c

===================================================================

diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c
index d6fe5e5..c3e8898 100644
--- a/source/blender/blenlib/intern/fileops.c
+++ b/source/blender/blenlib/intern/fileops.c
@@ -657,21 +657,29 @@ static int delete_single_file(const char *from, const char *UNUSED(to))
 
 FILE *BLI_fopen(const char *filename, const char *mode)
 {
+	BLI_assert(!BLI_path_is_rel(filename));
+
 	return fopen(filename, mode);
 }
 
 void *BLI_gzopen(const char *filename, const char *mode)
 {
+	BLI_assert(!BLI_path_is_rel(filename));
+
 	return gzopen(filename, mode);
 }
 
 int BLI_open(const char *filename, int oflag, int pmode)
 {
+	BLI_assert(!BLI_path_is_rel(filename));
+
 	return open(filename, oflag, pmode);
 }
 
 int   BLI_access(const char *filename, int mode)
 {
+	BLI_assert(!BLI_path_is_rel(filename));
+
 	return access(filename, mode);
 }
 
@@ -682,6 +690,8 @@ int   BLI_access(const char *filename, int mode)
  */
 int BLI_delete(const char *file, bool dir, bool recursive)
 {
+	BLI_assert(!BLI_path_is_rel(file));
+
 	if (recursive) {
 		return recursive_operation(file, NULL, NULL, delete_single_file, delete_callback_post);
 	}
diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c
index 7b7733d..7fdf6ec 100644
--- a/source/blender/blenlib/intern/storage.c
+++ b/source/blender/blenlib/intern/storage.c
@@ -227,6 +227,7 @@ int BLI_exists(const char *name)
 #else
 	struct stat st;
 	BLI_assert(name);
+	BLI_assert(!BLI_path_is_rel(name));
 	if (stat(name, &st)) return(0);
 #endif
 	return(st.st_mode);




More information about the Bf-blender-cvs mailing list