diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-08-17 21:07:31 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-08-17 21:07:31 +0200 |
| commit | a7c024e8ae449298b2805037e14184492dfb408e (patch) | |
| tree | af959d0147550118781721b100b81ad7f0abadfd | |
| parent | fc7e8b57fc79baf0a93b5ab4c14efe839e6f8f43 (diff) | |
| download | kernel-a7c024e8ae449298b2805037e14184492dfb408e.tar.xz kernel-a7c024e8ae449298b2805037e14184492dfb408e.zip | |
kapi/fs: introduce seek API
| -rw-r--r-- | kapi/kapi/filesystem.hpp | 9 | ||||
| -rw-r--r-- | kapi/kapi/filesystem/seek_origin.hpp | 22 |
2 files changed, 31 insertions, 0 deletions
diff --git a/kapi/kapi/filesystem.hpp b/kapi/kapi/filesystem.hpp index 956dc116..8972f9d3 100644 --- a/kapi/kapi/filesystem.hpp +++ b/kapi/kapi/filesystem.hpp @@ -7,6 +7,7 @@ #include <kapi/filesystem/device_number.hpp> // IWYU pragma: export #include <kapi/filesystem/file_status.hpp> // IWYU pragma: export #include <kapi/filesystem/file_type.hpp> // IWYU pragma: export +#include <kapi/filesystem/seek_origin.hpp> // IWYU pragma: export #include <kstd/result.hpp> #include <kstd/system_error.hpp> @@ -66,6 +67,14 @@ namespace kapi::filesystem //! @return The number of bytes written on success, an error code otherwise. auto write(size_t file_descriptor, std::span<std::byte const> buffer) -> kstd::result<kstd::units::bytes>; + //! Adjust the current position in the file. + //! + //! @param file_descriptor The file descriptor to seek. + //! @param offset The offset to seek to, relative to @p origin. + //! @param origin The origing to seek relatively to. + //! @return The new position in the file on success, an error code otherwise. + auto seek(size_t file_descriptor, kstd::units::bytes offset, seek_origin origin) -> kstd::result<kstd::units::bytes>; + //! Create a new directory at the specified path. //! //! @param path The path where the new directory should be created. diff --git a/kapi/kapi/filesystem/seek_origin.hpp b/kapi/kapi/filesystem/seek_origin.hpp new file mode 100644 index 00000000..4307f451 --- /dev/null +++ b/kapi/kapi/filesystem/seek_origin.hpp @@ -0,0 +1,22 @@ +#ifndef TEACHOS_KAPI_FILESYSTEM_SEEK_ORIGIN_HPP +#define TEACHOS_KAPI_FILESYSTEM_SEEK_ORIGIN_HPP + +// IWYU pragma: private, include <kapi/filesystem.hpp> + +namespace kapi::filesystem +{ + + //! The origin for a seek operation. + enum class seek_origin + { + //! Seek from the beginning of the file. + beginning, + //! Seek from the current position. + current_position, + //! Seek from the end of the file. + end, + }; + +} // namespace kapi::filesystem + +#endif
\ No newline at end of file |
