BLI_delete: assert that dir is true when recursive is true

While this isn't an error avoid ambiguity for recursive deletion
as it's not meaningful to delete a file.
This commit is contained in:
Campbell Barton 2024-03-21 09:43:40 +11:00
parent 4e3771124d
commit fbe16bc1eb
2 changed files with 6 additions and 1 deletions

View File

@ -734,6 +734,9 @@ int BLI_delete(const char *path, bool dir, bool recursive)
BLI_assert(!BLI_path_is_rel(path));
/* Not an error but avoid ambiguous arguments (recursive file deletion isn't meaningful). */
BLI_assert(!(dir == false && recursive == true));
if (recursive) {
err = delete_recursive(path);
}
@ -1281,6 +1284,8 @@ int BLI_access(const char *filepath, int mode)
int BLI_delete(const char *path, bool dir, bool recursive)
{
BLI_assert(!BLI_path_is_rel(path));
/* Not an error but avoid ambiguous arguments (recursive file deletion isn't meaningful). */
BLI_assert(!(dir == false && recursive == true));
if (recursive) {
return recursive_operation(path, nullptr, nullptr, delete_single_file, delete_callback_post);

View File

@ -361,7 +361,7 @@ static void seq_disk_cache_handle_versioning(SeqDiskCache *disk_cache)
}
if (version != DCACHE_CURRENT_VERSION) {
BLI_delete(dirpath, false, true);
BLI_delete(dirpath, true, true);
seq_disk_cache_create_version_file(path_version_file);
}
}