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:
authorCampbell Barton <ideasman42@gmail.com>2013-08-29 09:34:58 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-08-29 09:34:58 +0400
commitbd2f6c590707f6677da5ad84d29c10029936f2cf (patch)
treeb54ea59a8252afca5436bbc68993fe44c619f253 /source/blender/blenlib
parentdea537fd68e0b8c3b3e2fb377a9f4ee0ab897ece (diff)
default blend file name setting (untitled.blend) length check wasn't correct, move to generic function BLI_ensure_filename().
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_path_util.h1
-rw-r--r--source/blender/blenlib/intern/path_util.c10
2 files changed, 11 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h
index cb812fe8595..113c511a4f7 100644
--- a/source/blender/blenlib/BLI_path_util.h
+++ b/source/blender/blenlib/BLI_path_util.h
@@ -122,6 +122,7 @@ bool BLI_testextensie_array(const char *str, const char **ext_array);
bool BLI_testextensie_glob(const char *str, const char *ext_fnmatch);
bool BLI_replace_extension(char *path, size_t maxlen, const char *ext);
bool BLI_ensure_extension(char *path, size_t maxlen, const char *ext);
+bool BLI_ensure_filename(char *filepath, size_t maxlen, const char *filename);
void BLI_uniquename(struct ListBase *list, void *vlink, const char *defname, char delim, short name_offs, short len);
bool BLI_uniquename_cb(bool (*unique_check)(void *arg, const char *name),
void *arg, const char * defname, char delim, char *name, short name_len);
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index 4d6c9797ed1..bcdc226a2a7 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -1641,6 +1641,16 @@ bool BLI_ensure_extension(char *path, size_t maxlen, const char *ext)
return true;
}
+bool BLI_ensure_filename(char *filepath, size_t maxlen, const char *filename)
+{
+ char *c = (char *)BLI_last_slash(filepath);
+ if (!c || ((c - filepath) < maxlen - (strlen(filename) + 1))) {
+ strcpy(c ? &c[1] : filepath, filename);
+ return true;
+ }
+ return false;
+}
+
/* Converts "/foo/bar.txt" to "/foo/" and "bar.txt"
* - wont change 'string'
* - wont create any directories