delete_directory fails silently on subfolders

This commit is contained in:
Nathan Phillips 2017-03-17 10:59:21 +00:00
parent a7663cb997
commit b63228c675
1 changed files with 7 additions and 1 deletions

View File

@ -107,7 +107,13 @@ void delete_directory(const std::string &path)
struct dirent *ent; struct dirent *ent;
while((ent=readdir(dir))!=NULL) while((ent=readdir(dir))!=NULL)
remove((path+"/"+ent->d_name).c_str()); {
std::string sub_path=path+"/"+ent->d_name;
if(ent->d_type==DT_DIR)
delete_directory(sub_path);
else
remove(sub_path.c_str());
}
closedir(dir); closedir(dir);
} }