diff options
author | eldritch horrors <pennae@lix.systems> | 2024-03-24 00:44:57 +0100 |
---|---|---|
committer | eldritch horrors <pennae@lix.systems> | 2024-07-05 22:28:16 +0000 |
commit | f4f6d1d8e24a092422fcec601e21683179b735c9 (patch) | |
tree | e90edb17aea9aefc7449d1b3723ffb3b0a5bec59 /src/libutil/file-system.cc | |
parent | 06220a71c1430c97bfcd8012b00530a987e40e97 (diff) |
libutil: convert readFileSource to a generator
Change-Id: I5f92b15fd367d46eb047d74ab6e317b4f51a46d3
Diffstat (limited to 'src/libutil/file-system.cc')
-rw-r--r-- | src/libutil/file-system.cc | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/src/libutil/file-system.cc b/src/libutil/file-system.cc index 871707468..13c2b27eb 100644 --- a/src/libutil/file-system.cc +++ b/src/libutil/file-system.cc @@ -289,17 +289,12 @@ std::string readFile(const Path & path) } -box_ptr<Source> readFileSource(const Path & path) +Generator<Bytes> readFileSource(const Path & path) { AutoCloseFD fd{open(path.c_str(), O_RDONLY | O_CLOEXEC)}; if (!fd) throw SysError("opening file '%s'", path); - - struct FileSource : FdSource { - AutoCloseFD fd; - explicit FileSource(AutoCloseFD fd) : FdSource(fd.get()), fd(std::move(fd)) {} - }; - return make_box_ptr<FileSource>(std::move(fd)); + co_yield drainFDSource(fd.get()); } |