refactor: wrap std::filesystem::space calls (#8284)

Co-authored-by: Charles Kerr <charles@charleskerr.com>
This commit is contained in:
Yat Ho
2026-01-31 01:18:04 +08:00
committed by GitHub
parent c4283e0c8f
commit 3a8a4d9b86
4 changed files with 70 additions and 36 deletions

View File

@@ -11,7 +11,6 @@
#include "libtransmission/error.h"
#include "libtransmission/file.h"
#include "libtransmission/tr-assert.h"
std::string tr_sys_path_resolve(std::string_view path, tr_error* error)
{
@@ -65,3 +64,19 @@ std::vector<std::string> tr_sys_dir_get_files(
}
}
}
std::optional<std::filesystem::space_info> tr_sys_path_get_capacity(std::filesystem::path const& path, tr_error* error)
{
auto ec = std::error_code{};
auto space = std::filesystem::space(path, ec);
if (!ec)
{
return space;
}
if (error != nullptr)
{
error->set(ec.value(), ec.message());
}
return {};
}