From a7c024e8ae449298b2805037e14184492dfb408e Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Mon, 17 Aug 2026 21:07:31 +0200 Subject: kapi/fs: introduce seek API --- kapi/kapi/filesystem.hpp | 9 +++++++++ kapi/kapi/filesystem/seek_origin.hpp | 22 ++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 kapi/kapi/filesystem/seek_origin.hpp (limited to 'kapi') 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 // IWYU pragma: export #include // IWYU pragma: export #include // IWYU pragma: export +#include // IWYU pragma: export #include #include @@ -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 buffer) -> kstd::result; + //! 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; + //! 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 + +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 -- cgit v1.2.3