if (sp.is_directory())
{
- DIR *dir = opendir(path.c_str());
- if (!dir)
- throw runtime_error("can't open directory " + path);
-
- struct dirent store, *entry = NULL;
- while (readdir_r(dir, &store, &entry) == 0 && entry != NULL)
+ std::vector<std::string> dirents = get_dir(path, false);
+ BOOST_FOREACH(const std::string &filename, dirents)
{
- string filename = entry->d_name;
- if (filename == "." || filename == "..")
- continue;
-
// Delete subdir or file.
rtn = recursive_delete(path + "/" + filename, false, error);
if (rtn == false)
break;
}
- closedir(dir);
if (keep_parent_dir == false && !rmdir(path))
throw runtime_error("can't remove directory " + path);
}