diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-08-29 09:34:58 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-08-29 09:34:58 +0400 |
commit | bd2f6c590707f6677da5ad84d29c10029936f2cf (patch) | |
tree | b54ea59a8252afca5436bbc68993fe44c619f253 /source/blender/blenlib/intern/path_util.c | |
parent | dea537fd68e0b8c3b3e2fb377a9f4ee0ab897ece (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/intern/path_util.c')
-rw-r--r-- | source/blender/blenlib/intern/path_util.c | 10 |
1 files changed, 10 insertions, 0 deletions
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 |