From 493f50c697b17049b820e65664af9f4a7c9c0c2c Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Tue, 18 Aug 2026 00:25:29 +0200 Subject: kapi: implement seek support --- kapi/kapi/filesystem.hpp | 8 +++++--- kapi/kapi/filesystem/seek.hpp | 30 ++++++++++++++++++++++++++++++ kapi/kapi/filesystem/seek_origin.hpp | 22 ---------------------- 3 files changed, 35 insertions(+), 25 deletions(-) create mode 100644 kapi/kapi/filesystem/seek.hpp delete mode 100644 kapi/kapi/filesystem/seek_origin.hpp (limited to 'kapi') diff --git a/kapi/kapi/filesystem.hpp b/kapi/kapi/filesystem.hpp index 8972f9d3..be754748 100644 --- a/kapi/kapi/filesystem.hpp +++ b/kapi/kapi/filesystem.hpp @@ -7,7 +7,7 @@ #include // IWYU pragma: export #include // IWYU pragma: export #include // IWYU pragma: export -#include // IWYU pragma: export +#include // IWYU pragma: export #include #include @@ -70,10 +70,12 @@ namespace kapi::filesystem //! 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 offset The offset to seek to, relative to the origin. + //! @param direction The direction to seek towards, relative to the 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; + auto seek(size_t file_descriptor, kstd::units::bytes offset, seek_direction direction, seek_origin origin) + -> kstd::result; //! Create a new directory at the specified path. //! diff --git a/kapi/kapi/filesystem/seek.hpp b/kapi/kapi/filesystem/seek.hpp new file mode 100644 index 00000000..f1006f31 --- /dev/null +++ b/kapi/kapi/filesystem/seek.hpp @@ -0,0 +1,30 @@ +#ifndef TEACHOS_KAPI_FILESYSTEM_SEEK_HPP +#define TEACHOS_KAPI_FILESYSTEM_SEEK_HPP + +// IWYU pragma: private, include + +namespace kapi::filesystem +{ + + //! The origin for a seek operation. + enum struct 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, + }; + + enum struct seek_direction + { + //! seek forward from the origin. + forward, + //! seek backward from the origin. + backward, + }; + +} // namespace kapi::filesystem + +#endif \ No newline at end of file diff --git a/kapi/kapi/filesystem/seek_origin.hpp b/kapi/kapi/filesystem/seek_origin.hpp deleted file mode 100644 index 4307f451..00000000 --- a/kapi/kapi/filesystem/seek_origin.hpp +++ /dev/null @@ -1,22 +0,0 @@ -#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