diff options
| author | Lexi Winter <lexi@le-fay.org> | 2025-07-01 17:07:04 +0100 |
|---|---|---|
| committer | Lexi Winter <lexi@le-fay.org> | 2025-07-01 17:07:04 +0100 |
| commit | 2e2d1bd3b6c7776b77c33b94f30ead89367a71e6 (patch) | |
| tree | 54d37ffadf8e677938d9b7a28e4e9b71be1e75c1 /nihil.posix/read_file.ccm | |
| parent | 36427c0966faa7aecd586b397ed9b845f18172f5 (diff) | |
| download | nihil-2e2d1bd3b6c7776b77c33b94f30ead89367a71e6.tar.gz nihil-2e2d1bd3b6c7776b77c33b94f30ead89367a71e6.tar.bz2 | |
add nihil.std
Diffstat (limited to 'nihil.posix/read_file.ccm')
| -rw-r--r-- | nihil.posix/read_file.ccm | 27 |
1 files changed, 4 insertions, 23 deletions
diff --git a/nihil.posix/read_file.ccm b/nihil.posix/read_file.ccm index 3b4fd5b..61c5085 100644 --- a/nihil.posix/read_file.ccm +++ b/nihil.posix/read_file.ccm @@ -1,20 +1,4 @@ -/* - * This source code is released into the public domain. - */ - -module; - -#include <algorithm> -#include <expected> -#include <filesystem> -#include <iterator> -#include <ranges> -#include <span> -#include <system_error> - -#include <fcntl.h> -#include <unistd.h> - +// This source code is released into the public domain. export module nihil.posix:read_file; import nihil.error; @@ -24,12 +8,9 @@ import :open; namespace nihil { -/* - * Read the contents of a file into an output iterator. - */ +// Read the contents of a file into an output iterator. export [[nodiscard]] auto -read_file(std::filesystem::path const &filename, - std::output_iterator<char> auto &&iter) +read_file(std::filesystem::path const &filename, std::output_iterator<char> auto &&iter) -> std::expected<void, error> { auto file = co_await open(filename, open_read); @@ -38,7 +19,7 @@ read_file(std::filesystem::path const &filename, auto buffer = std::array<char, bufsize>{}; for (;;) { - auto read_buf = co_await(read(file, buffer)); + auto read_buf = co_await (read(file, buffer)); if (read_buf.empty()) co_return {}; |
