diff options
Diffstat (limited to 'kapi')
| -rw-r--r-- | kapi/kapi/filesystem/block_special_file.hpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/kapi/kapi/filesystem/block_special_file.hpp b/kapi/kapi/filesystem/block_special_file.hpp index 0e44fe35..ada1edf2 100644 --- a/kapi/kapi/filesystem/block_special_file.hpp +++ b/kapi/kapi/filesystem/block_special_file.hpp @@ -9,6 +9,7 @@ #include <kstd/units.hpp> #include <cstddef> +#include <span> namespace kapi::filesystem { @@ -22,22 +23,28 @@ namespace kapi::filesystem //! Read data from a block into a given buffer. //! - //! If the selected block is smaller than the buffer, a partial read will occur. + //! A partial read occurs if either the block size is smaller than the provided buffer, or the provided buffer is + //! smaller than the block size. In the first case, the bytes of the buffer beyond the block size will remain + //! untouched. //! //! @param block_index The number of the block to read from. //! @param buffer The buffer to read into. //! @return The number of bytes read on success, an error otherwise. - [[nodiscard]] auto virtual read_block(size_t block_index, void * buffer) const + [[nodiscard]] auto virtual read_block(size_t block_index, std::span<std::byte> buffer) const -> kstd::result<kstd::units::bytes> = 0; //! Write data from a buffer into a block. //! - //! If the buffer is larger than the selected block, a partial write will occur. + //! A partial write occurs if either the block size if smaller than the provided buffer, or the provided buffer is + //! smaller than the block size. In the first case, the bytes of the buffer beyond the block size are ignored and + //! not written to the device. In the second case, the bytes of the block beyond the buffer size will remain + //! untouched. //! //! @param block_index The number of the block to write to. //! @param buffer The buffer to write from. //! @return The number of bytes written on success, an error otherwise. - auto virtual write_block(std::size_t block_index, void const * buffer) -> kstd::result<kstd::units::bytes> = 0; + auto virtual write_block(std::size_t block_index, std::span<std::byte const> buffer) + -> kstd::result<kstd::units::bytes> = 0; //! Get the block size in bytes. [[nodiscard]] auto virtual block_size() const -> kstd::units::bytes = 0; |
