From 1c883fe6468c9fd3859d24e63590d4011984d52e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 15 Feb 2020 10:33:16 +1100 Subject: Cleanup: make BLI_make_exist local to the file selector This isn't a general utility, and the name wasn't descriptive. --- source/blender/blenlib/intern/path_util.c | 38 ++++++++++++------------------- 1 file changed, 15 insertions(+), 23 deletions(-) (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 dff1f77c1ab..f8e703dbb56 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -728,6 +728,21 @@ bool BLI_parent_dir(char *path) } } +/** + * Strips off nonexistent (or non-accessible) subdirectories from the end of *dir, + * leaving the path of the lowest-level directory that does exist and we can read. + */ +bool BLI_parent_dir_until_exists(char *dir) +{ + bool valid_path = true; + + /* Loop as long as cur path is not a dir, and we can get a parent path. */ + while ((BLI_access(dir, R_OK) != 0) && (valid_path = BLI_parent_dir(dir))) { + /* pass */ + } + return (valid_path && dir[0]); +} + /** * Looks for a sequence of "#" characters in the last slash-separated component of *path, * returning the indexes of the first and one past the last character in the sequence in @@ -1312,29 +1327,6 @@ const char *BLI_getenv(const char *env) #endif } -/** - * Strips off nonexistent (or non-accessible) subdirectories from the end of *dir, - * leaving the path of the lowest-level directory that does exist and we can read. - */ -void BLI_make_exist(char *dir) -{ - bool valid_path = true; - - /* Loop as long as cur path is not a dir, and we can get a parent path. */ - while ((BLI_access(dir, R_OK) != 0) && (valid_path = BLI_parent_dir(dir))) { - /* pass */ - } - - /* If we could not find an existing dir, use default root... */ - if (!valid_path || !dir[0]) { -#ifdef WIN32 - get_default_root(dir); -#else - strcpy(dir, "/"); -#endif - } -} - /** * Ensures that the parent directory of *name exists. * -- cgit v1.2.3