From: Gerd von Egidy Date: Wed, 16 Dec 2015 22:36:50 +0000 (+0100) Subject: sanitize indent so that I can work with this code X-Git-Tag: v2.8~11 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=854d7ee86cd04e4d370667e8a67513ff4203ca1a;p=libi2ncommon sanitize indent so that I can work with this code --- diff --git a/src/filefunc.cpp b/src/filefunc.cpp index 3a7f7c1..c71b27d 100644 --- a/src/filefunc.cpp +++ b/src/filefunc.cpp @@ -747,51 +747,55 @@ bool recursive_delete(const std::string &path, { bool rtn = true; - try { + try + { struct stat my_stat; - if (stat(path.c_str(), &my_stat) != 0) { + if (stat(path.c_str(), &my_stat) != 0) throw runtime_error("can't stat " + path); - } - if (S_ISDIR(my_stat.st_mode)) { + if (S_ISDIR(my_stat.st_mode)) + { DIR *dir = opendir(path.c_str()); - if (!dir) { + if (!dir) throw runtime_error("can't open directory " + path); - } struct dirent store, *entry = NULL; while (readdir_r(dir, &store, &entry) == 0 && entry != NULL) { string filename = entry->d_name; - if (filename == "." || filename == "..") { + if (filename == "." || filename == "..") continue; - } // Delete subdir or file. rtn = recursive_delete(path + "/" + filename, false, error); - if (rtn == false) { + if (rtn == false) break; - } } closedir(dir); - if (keep_parent_dir == false && !rmdir(path)) { + if (keep_parent_dir == false && !rmdir(path)) throw runtime_error("can't remove directory " + path); - } - } else { - if (!unlink(path)) { + } + else + { + if (!unlink(path)) throw runtime_error("can't unlink " + path); - } } - } catch (exception &e) { - if (error) { + } + catch (exception &e) + { + if (error) + { ostringstream out; out << e.what() << " (" << strerror(errno) << ")"; *error = out.str(); } rtn = false; - } catch (...) { - if (error) { + } + catch (...) + { + if (error) + { ostringstream out; out << "unknown error (" << strerror(errno) << ")"; *error = out.str();