]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
enhance: Support nonstd::span<const uint8_t> for util::write_file
authorJoel Rosdahl <joel@rosdahl.net>
Sat, 3 Sep 2022 11:59:23 +0000 (13:59 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Mon, 5 Sep 2022 11:01:49 +0000 (13:01 +0200)
src/util/file.cpp
src/util/file.hpp

index d50d027b743d1c8937a6e914bb02db81e901fdaa..77b24b539984daf646bbd4338319df0397aad79a 100644 (file)
@@ -246,7 +246,7 @@ write_file(const std::string& path, const std::string& data)
 }
 
 nonstd::expected<void, std::string>
-write_file(const std::string& path, const util::Blob& data)
+write_file(const std::string& path, nonstd::span<const uint8_t> data)
 {
   Fd fd(open(path.c_str(), O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666));
   if (!fd) {
index 886740ff172c7637bdcd16ecd33c473233efe45a..dc6596c862f53ac27956886ca34797b4828fc193 100644 (file)
@@ -21,6 +21,7 @@
 #include <util/types.hpp>
 
 #include <third_party/nonstd/expected.hpp>
+#include <third_party/nonstd/span.hpp>
 
 #include <ctime>
 #include <optional>
@@ -60,7 +61,7 @@ nonstd::expected<void, std::string> write_file(const std::string& path,
                                                const std::string& data);
 
 // Write binary `data` to `path`.
-nonstd::expected<void, std::string> write_file(const std::string& path,
-                                               const util::Blob& data);
+nonstd::expected<void, std::string>
+write_file(const std::string& path, nonstd::span<const uint8_t> data);
 
 } // namespace util