From: Gerd von Egidy Date: Wed, 16 Dec 2015 23:04:39 +0000 (+0100) Subject: also replace opendir() by our get_dir(), you get eye cancer when looking at the c... X-Git-Tag: v2.8~9 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=8decfb5a2798b8872d0dee9d8674c3d8473baa54;p=libi2ncommon also replace opendir() by our get_dir(), you get eye cancer when looking at the c functions --- diff --git a/src/filefunc.cpp b/src/filefunc.cpp index a19d760..575be4d 100644 --- a/src/filefunc.cpp +++ b/src/filefunc.cpp @@ -755,24 +755,15 @@ bool recursive_delete(const std::string &path, 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 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); }