diff --git a/libi2pd/FS.cpp b/libi2pd/FS.cpp index 7334550f..9b76dea7 100644 --- a/libi2pd/FS.cpp +++ b/libi2pd/FS.cpp @@ -270,6 +270,15 @@ namespace fs { boost::filesystem::remove(path); } + void HashedStorage::Destroy() { + std::string storage_root = GetRoot (); + if (storage_root.empty()) { + LogPrint(eLogError, "FS: you're trying to call HashedStorage.Destroy() before .SetPlace(), fix your code!"); + return; + } + boost::filesystem::remove_all(storage_root); + } + void HashedStorage::Traverse(std::vector & files) { Iterate([&files] (const std::string & fname) { files.push_back(fname); diff --git a/libi2pd/FS.h b/libi2pd/FS.h index 7911c6a0..cd3e85ed 100644 --- a/libi2pd/FS.h +++ b/libi2pd/FS.h @@ -65,6 +65,8 @@ namespace fs { void Traverse(std::vector & files); /** visit every file in this storage with a visitor */ void Iterate(FilenameVisitor v); + /** remove ALL contents of storage and it's root dir */ + void Destroy(); }; /** @brief Returns current application name, default 'i2pd' */