aboutsummaryrefslogtreecommitdiffstats
path: root/nihil.posix/posix.read_file.ccm
diff options
context:
space:
mode:
Diffstat (limited to 'nihil.posix/posix.read_file.ccm')
-rw-r--r--nihil.posix/posix.read_file.ccm48
1 files changed, 0 insertions, 48 deletions
diff --git a/nihil.posix/posix.read_file.ccm b/nihil.posix/posix.read_file.ccm
deleted file mode 100644
index c950f67..0000000
--- a/nihil.posix/posix.read_file.ccm
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * This source code is released into the public domain.
- */
-
-module;
-
-#include <expected>
-#include <filesystem>
-#include <iterator>
-#include <ranges>
-#include <span>
-#include <system_error>
-
-#include <fcntl.h>
-#include <unistd.h>
-
-export module nihil.posix:read_file;
-
-import nihil.error;
-import nihil.monad;
-import :fd;
-import :open;
-
-namespace nihil {
-
-/*
- * 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)
- -> std::expected<void, error>
-{
- auto file = co_await open(filename, O_RDONLY);
-
- auto constexpr bufsize = std::size_t{1024};
- auto buffer = std::array<char, bufsize>{};
-
- for (;;) {
- auto read_buf = co_await(read(file, buffer));
- if (read_buf.empty())
- co_return {};
-
- std::ranges::copy(read_buf, iter);
- }
-}
-
-} // namespace nihil