From bd2f6c590707f6677da5ad84d29c10029936f2cf Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 29 Aug 2013 05:34:58 +0000 Subject: default blend file name setting (untitled.blend) length check wasn't correct, move to generic function BLI_ensure_filename(). --- source/blender/blenlib/intern/path_util.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source/blender/blenlib/intern/path_util.c') 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 -- cgit v1.2.3