Make use of "ensure_directory" function (#1765)

This commit is contained in:
Mark Thompson 2024-01-13 00:57:32 -06:00 committed by GitHub
parent 409242507c
commit 58307aee9c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 10 additions and 24 deletions

View file

@ -53,7 +53,6 @@ class UnTar {
}
static bool create_dir(char* pathname) {
char* p;
std::filesystem::filesystem_error r;
if (!isValidName(pathname)) return false;
@ -65,18 +64,7 @@ class UnTar {
std::string dirnameStr = u'/' + pathname;
std::filesystem::path dirname = dirnameStr;
r = make_new_directory(dirname);
if (!r.ok()) {
/* On failure, try creating parent directory. */
p = strrchr(pathname, '/');
if (p != NULL) {
*p = '\0';
create_dir(pathname);
*p = '/';
r = make_new_directory(dirname);
}
}
r = ensure_directory(dirname);
return (r.ok());
}