+ HashedStorage::Destroy()

This commit is contained in:
hagen 2023-05-15 00:00:00 +00:00
parent 5a09c11e90
commit d010d3575d
2 changed files with 11 additions and 0 deletions

View file

@ -270,6 +270,15 @@ namespace fs {
boost::filesystem::remove(path); 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<std::string> & files) { void HashedStorage::Traverse(std::vector<std::string> & files) {
Iterate([&files] (const std::string & fname) { Iterate([&files] (const std::string & fname) {
files.push_back(fname); files.push_back(fname);

View file

@ -65,6 +65,8 @@ namespace fs {
void Traverse(std::vector<std::string> & files); void Traverse(std::vector<std::string> & files);
/** visit every file in this storage with a visitor */ /** visit every file in this storage with a visitor */
void Iterate(FilenameVisitor v); void Iterate(FilenameVisitor v);
/** remove ALL contents of storage and it's root dir */
void Destroy();
}; };
/** @brief Returns current application name, default 'i2pd' */ /** @brief Returns current application name, default 'i2pd' */