From 5adbe389b8ac0c3d705d40b311120c1d6a064e91 Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Tue, 6 Sep 2016 11:29:59 +0200 Subject: [PATCH] CFileHelpers::removeDir: Better error message - No error when directory does not exist Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/79b94cdfad40e2a309c9a78ac9a774056c4241eb Author: Michael Liebmann Date: 2016-09-06 (Tue, 06 Sep 2016) --- src/system/helpers.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/system/helpers.cpp b/src/system/helpers.cpp index 2b2dbc8e5..39f49efcd 100644 --- a/src/system/helpers.cpp +++ b/src/system/helpers.cpp @@ -1068,8 +1068,14 @@ bool CFileHelpers::removeDir(const char *Dir) dir = opendir(Dir); if (dir == NULL) { - fh->setDebugInfo("Error opendir().", __path_file__, __func__, __LINE__); - fh->printDebugInfo(); + if (errno == ENOENT) + return true; + if (!fh->getConsoleQuiet()) + dprintf(DEBUG_NORMAL, "[CFileHelpers %s] remove directory %s: %s\n", __func__, Dir, strerror(errno)); + char buf[1024]; + memset(buf, '\0', sizeof(buf)); + snprintf(buf, sizeof(buf)-1, "remove directory %s: %s", Dir, strerror(errno)); + fh->setDebugInfo(buf, __path_file__, __func__, __LINE__); return false; } while ((entry = readdir(dir)) != NULL) {