This commit is contained in:
Your Name
2025-05-25 11:30:18 +12:00
parent 90b4946ce8
commit 52dcaada2d
6 changed files with 267 additions and 207 deletions

28
src/utils.cpp Normal file
View File

@@ -0,0 +1,28 @@
#include "utils.hpp"
namespace simple_object_storage
{
ScopeFileDeleter::ScopeFileDeleter(const std::filesystem::path &path) : path_(path), released_(false) {}
ScopeFileDeleter::~ScopeFileDeleter()
{
if (!released_)
{
try
{
if (std::filesystem::exists(path_))
{
std::filesystem::remove(path_);
}
}
catch (const std::filesystem::filesystem_error &e)
{
std::cerr << "Error deleting temp file: " << path_ << " - " << e.what() << std::endl;
}
}
}
void ScopeFileDeleter::release() { released_ = true; }
}