29 lines
709 B
C++
29 lines
709 B
C++
#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; }
|
|
|
|
}
|