commits
tags
#include "torlinkc/engine/delete_data.hpp"
#include <filesystem>
namespace fs = std::filesystem;
namespace torlinkc {
namespace {
std::string trim(const std::string& s) {
auto first = s.find_first_not_of(" \t\r\n");
if (first == std::string::npos) return "";
auto last = s.find_last_not_of(" \t\r\n");
return s.substr(first, last - first + 1);
}
} // namespace
std::optional<std::string> deleteSeedData(const std::string& dir, const std::string& name) {
const std::string base = fs::path(trim(name)).filename().string();
if (base.empty() || base == "." || base == "..") return std::nullopt;
fs::path target = fs::path(dir) / base;
std::error_code ec;
fs::remove_all(target, ec); // best-effort: errors are swallowed, same as the original
return target.string();
}
} // namespace torlinkc