From 8decfb5a2798b8872d0dee9d8674c3d8473baa54 Mon Sep 17 00:00:00 2001 From: Gerd von Egidy Date: Thu, 17 Dec 2015 00:04:39 +0100 Subject: [PATCH] also replace opendir() by our get_dir(), you get eye cancer when looking at the c functions --- src/filefunc.cpp | 13 ++----------- 1 files changed, 2 insertions(+), 11 deletions(-) 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); } -- 1.7.1