mirror of
https://github.com/transmission/transmission.git
synced 2026-02-15 07:26:49 +00:00
refactor: wrap std::filesystem::space calls (#8284)
Co-authored-by: Charles Kerr <charles@charleskerr.com>
This commit is contained in:
@@ -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 {};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user