23 [[nodiscard]]
constexpr bool valid() const noexcept
34 return lhs.value == rhs.value;
52 return static_cast<OpenMode>(
static_cast<std::uint8_t
>(lhs) |
static_cast<std::uint8_t
>(rhs));
58 return static_cast<OpenMode>(
static_cast<std::uint8_t
>(lhs) &
static_cast<std::uint8_t
>(rhs));
67 return static_cast<std::uint8_t
>(value & flag) != 0;
FileDescriptorTable(const FileDescriptorTable &)=delete
FileDescriptorTable & operator=(const FileDescriptorTable &)=delete
std::size_t openCount() const noexcept
Count of currently open descriptors.
Result< FileDescriptor > open(OpenFileState state)
Creates a new descriptor entry.
Result< void > set(FileDescriptor fd, OpenFileState state)
Replaces state for descriptor.
FileDescriptorTable(FileDescriptorTable &&) noexcept
Result< OpenFileState > get(FileDescriptor fd) const
Returns state for descriptor.
Result< void > close(FileDescriptor fd)
Removes a descriptor entry.
std::unique_ptr< Impl > impl_
bool contains(FileDescriptor fd) const noexcept
Returns whether descriptor exists.
A result type that holds either a success value of type T or an ErrorCode.
Error codes and Result<T> type for fallible operations.
Inode types for the SimpleFS file-system simulation.
constexpr OpenMode operator|(OpenMode lhs, OpenMode rhs) noexcept
Returns bitwise OR combination of open-mode flags.
constexpr OpenMode operator&(OpenMode lhs, OpenMode rhs) noexcept
Returns bitwise AND combination of open-mode flags.
constexpr InodeId INVALID_INODE_ID
Sentinel value indicating an invalid inode identifier.
constexpr bool hasOpenMode(OpenMode value, OpenMode flag) noexcept
Returns whether the provided mode set contains a flag.
std::uint32_t InodeId
Unique identifier for a filesystem inode.
OpenMode
Open mode bit flags.
Descriptor handle returned by open().
std::int32_t value
Underlying descriptor value.
friend constexpr bool operator==(FileDescriptor lhs, FileDescriptor rhs) noexcept
Equality comparison for descriptor values.
constexpr bool valid() const noexcept
Returns true when descriptor is valid.
Runtime state for one open descriptor.
InodeId inodeId
Target inode associated with descriptor.
std::size_t offset
Current byte offset.
OpenMode mode
Open mode flags for this descriptor.