Cleanup: avoid calling stat twice in BLI_dir_create_recursive

This commit is contained in:
Campbell Barton
2023-05-04 13:12:35 +10:00
parent aa7d7c8e4b
commit cf16eab370

View File

@@ -1296,11 +1296,12 @@ bool BLI_dir_create_recursive(const char *dirname)
char *tmp;
bool ret = true;
if (BLI_is_dir(dirname)) {
return true;
}
if (BLI_exists(dirname)) {
return false;
const int mode = BLI_exists(dirname);
if (mode != 0) {
/* The file exists, either it's a directory (ok), or not,
* in which case this function can't do anything useful
* (the caller could remove it and re-run this function). */
return S_ISDIR(mode) ? true : false;
}
# ifdef MAXPATHLEN