Tidy
This commit is contained in:
28
src/utils.cpp
Normal file
28
src/utils.cpp
Normal 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; }
|
||||
|
||||
}
|
Reference in New Issue
Block a user