From af634bd4e54eb851e41e6216da0ee0a8cfbe69f9 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Mon, 27 May 2024 00:44:58 -0500 Subject: [PATCH] [ox/fs] Add FileSystem::exists --- deps/ox/src/ox/fs/filesystem/filesystem.hpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/deps/ox/src/ox/fs/filesystem/filesystem.hpp b/deps/ox/src/ox/fs/filesystem/filesystem.hpp index 5cef1551..c39f556d 100644 --- a/deps/ox/src/ox/fs/filesystem/filesystem.hpp +++ b/deps/ox/src/ox/fs/filesystem/filesystem.hpp @@ -99,6 +99,21 @@ class FileSystem { Result stat(const FileAddress &addr) const noexcept; + [[nodiscard]] + inline bool exists(uint64_t inode) const noexcept { + return statInode(inode).ok(); + } + + [[nodiscard]] + inline bool exists(ox::StringView path) const noexcept { + return statPath(path).ok(); + } + + [[nodiscard]] + inline bool exists(FileAddress const&addr) const noexcept { + return stat(addr).ok(); + } + [[nodiscard]] virtual uint64_t spaceNeeded(uint64_t size) const noexcept = 0;