diff --git a/src/PityUnit.hh b/src/PityUnit.hh index ab60365..0aeb316 100644 --- a/src/PityUnit.hh +++ b/src/PityUnit.hh @@ -95,11 +95,6 @@ namespace pEp { Utils::Color _termColor() const; void logRaw(const std::string& msg) const; - // Dirs - void _ensureDir(const std::string& path) const; - void _recreateDir(const std::string& path) const; - - // Fields const std::string _name; const PityUnit* _parent; //nullptr if RootUnit diff --git a/src/PityUnit.hxx b/src/PityUnit.hxx index cccfe9b..10e44b3 100644 --- a/src/PityUnit.hxx +++ b/src/PityUnit.hxx @@ -5,7 +5,6 @@ #define PITYTEST_PITYUNIT_HXX #include "../../../src/std_utils.hh" -//#include "../../framework/utils.hh" #include #include #include @@ -284,7 +283,7 @@ namespace pEp { logRaw(to_string()); logH3("INIT"); - _ensureDir(getGlobalRootDir()); + Utils::dir_ensure(getGlobalRootDir()); recreateDirsRecursively(); // if (!_children.empty()) { // for (const std::pair&> child : _children) { @@ -468,34 +467,11 @@ namespace pEp { Adapter::pEpLog::log(msg, _termColor()); } - template - void PityUnit::_ensureDir(const std::string& path) const - { - if (!Utils::path_exists(path)) { - logRaw("creating dir:" + path); - Utils::dir_create(path); - } - } - - template - void PityUnit::_recreateDir(const std::string& path) const - { - if (Utils::path_exists(path)) { - try { - logRaw("deleting dir:" + path); - Utils::path_delete_all(path); - } catch (const std::exception& e) { - logRaw("PityUnit: - could not delete data dir: " + getGlobalRootDir()); - } - } - logRaw("creating dir:" + path); - Utils::dir_create(path); - } template void PityUnit::recreateDirsRecursively() const { - _recreateDir(processDir()); + Utils::dir_recreate(processDir()); if (!_children.empty()) { for (const std::pair&> child : _children) { child.second.recreateDirsRecursively();