]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
refactor: Use new util::Blob typedef
authorJoel Rosdahl <joel@rosdahl.net>
Mon, 15 Aug 2022 19:15:53 +0000 (21:15 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Mon, 15 Aug 2022 20:13:32 +0000 (22:13 +0200)
src/AtomicFile.cpp
src/AtomicFile.hpp
unittest/test_AtomicFile.cpp

index f85957379c2d4ad6a1301c836e52f1b3439a4253..9585df816a46e2dfcdf9d3ef0cd61e7fdc005a3c 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2019-2021 Joel Rosdahl and other contributors
+// Copyright (C) 2019-2022 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
@@ -50,7 +50,7 @@ AtomicFile::write(const std::string& data)
 }
 
 void
-AtomicFile::write(const std::vector<uint8_t>& data)
+AtomicFile::write(const util::Blob& data)
 {
   if (fwrite(data.data(), data.size(), 1, m_stream) != 1) {
     throw core::Error(
index 9dba4181f60d8048db2f8e28fe959cefd91429bf..2dffb25ffc38ea8386c6d2fa2aa0b2d3ce818438 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2019-2021 Joel Rosdahl and other contributors
+// Copyright (C) 2019-2022 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
 
 #pragma once
 
+#include <util/types.hpp>
+
 #include <cstdint>
 #include <cstdio>
 #include <string>
-#include <vector>
 
 // This class represents a file whose data will be atomically written to a path
 // by renaming a temporary file in place.
@@ -36,7 +37,7 @@ public:
   FILE* stream();
 
   void write(const std::string& data);
-  void write(const std::vector<uint8_t>& data);
+  void write(const util::Blob& data);
 
   // Close the temporary file and rename it to the destination file. Note: The
   // destructor will not do this automatically to avoid half-written data in the
index 7ac1dbfa9a786cd10fe792c4303ed26db0294a36..a572040c4d8fef668d57a9a648cbcd98ae01a9af 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2011-2020 Joel Rosdahl and other contributors
+// Copyright (C) 2011-2022 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
@@ -32,7 +32,7 @@ TEST_CASE("Base case")
 
   AtomicFile atomic_file("test", AtomicFile::Mode::text);
   atomic_file.write("h");
-  atomic_file.write(std::vector<uint8_t>{0x65, 0x6c});
+  atomic_file.write(util::Blob{0x65, 0x6c});
   fputs("lo", atomic_file.stream());
   atomic_file.commit();
   CHECK(Util::read_file("test") == "hello");