Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2015-01-16 20:48:59 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2015-01-16 20:48:59 +0300
commit585275325edb9988c9d6891c1fe571c63c81ceb1 (patch)
tree845eab67e07219a87b390b46c490843376c6aa27 /source/blender/blenlib
parentda8f16e288d667e8b8c487b3192f962d71dec3aa (diff)
Fix T43275: Crash on Render when using 'save buffer' and render layer name contains a '/'
Added a new BLI_path_utils func, `BLI_filename_make_safe()`, which for now simply replaces unsafe chars for paths (like '\' or '/') by an underscore...
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_path_util.h2
-rw-r--r--source/blender/blenlib/intern/path_util.c18
2 files changed, 20 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h
index bade390d056..8daaff1cea6 100644
--- a/source/blender/blenlib/BLI_path_util.h
+++ b/source/blender/blenlib/BLI_path_util.h
@@ -108,6 +108,8 @@ void BLI_cleanup_dir(const char *relabase, char *dir) ATTR_NONNULL(2);
/* doesn't touch trailing slash */
void BLI_cleanup_path(const char *relabase, char *path) ATTR_NONNULL(2);
+void BLI_filename_make_safe(char *fname) ATTR_NONNULL(1);
+
/* go back one directory */
bool BLI_parent_dir(char *path) ATTR_NONNULL();
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index 3fff22218e2..793f4d589cd 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -428,6 +428,24 @@ void BLI_cleanup_file(const char *relabase, char *path)
BLI_del_slash(path);
}
+
+/**
+ * Make given name safe to be used in paths.
+ *
+ * For now, simply replaces reserved chars (as listed in
+ * http://en.wikipedia.org/wiki/Filename#Reserved_characters_and_words )
+ * by underscores ('_').
+ */
+void BLI_filename_make_safe(char *fname)
+{
+ char *invalid = "/\\?%*:|\"<>. ";
+ char *c;
+
+ for (; *fname && (fname = strpbrk(fname, invalid)); fname++) {
+ *fname = '_';
+ }
+}
+
/**
* Does path begin with the special "//" prefix that Blender uses to indicate
* a path relative to the .blend file.