Storage: add no-replace rename, hard link and free-space query to FilePort (refs #53)

This commit is contained in:
faumaray committed 2026-12-04 00:19:21 +03:00
1 parent ac30650266
commit 217b20e37a
3 files changed
+148

No files matched your search

+14
View File
@@ -64,6 +64,17 @@ namespace Void::Storage
[[nodiscard]] virtual Result<void> rename_atomic(
const std::filesystem::path& from,
const std::filesystem::path& to) = 0;
/// Rename only when the destination does not exist (atomic on Linux).
[[nodiscard]] virtual Result<void> rename_noreplace(
const std::filesystem::path& from,
const std::filesystem::path& to) = 0;
/// Create a hard link; fails when the destination exists.
[[nodiscard]] virtual Result<void> hard_link(
const std::filesystem::path& from,
const std::filesystem::path& to) = 0;
/// Bytes available to this process on the filesystem holding `p`.
[[nodiscard]] virtual Result<std::uint64_t> available_space(
const std::filesystem::path& p) = 0;
[[nodiscard]] virtual Result<void> unlink_file(
const std::filesystem::path& p) = 0;
[[nodiscard]] virtual Result<void> sync_dir(
@@ -119,6 +130,9 @@ namespace Void::Storage
[[nodiscard]] Result<std::unique_ptr<DirLockHandle>> lock_directory(const std::filesystem::path& dir) override;
[[nodiscard]] Result<std::unique_ptr<FileHandle>> open_file(const std::filesystem::path& p, FileOpenMode mode) override;
[[nodiscard]] Result<void> rename_atomic(const std::filesystem::path& from, const std::filesystem::path& to) override;
[[nodiscard]] Result<void> rename_noreplace(const std::filesystem::path& from, const std::filesystem::path& to) override;
[[nodiscard]] Result<void> hard_link(const std::filesystem::path& from, const std::filesystem::path& to) override;
[[nodiscard]] Result<std::uint64_t> available_space(const std::filesystem::path& p) override;
[[nodiscard]] Result<void> unlink_file(const std::filesystem::path& p) override;
[[nodiscard]] Result<void> sync_dir(const std::filesystem::path& dir) override;
[[nodiscard]] Result<void> probe_durability_capabilities(const std::filesystem::path& dir) override;