From: Joel Rosdahl Date: Mon, 15 Aug 2022 19:15:53 +0000 (+0200) Subject: refactor: Use new util::Blob typedef X-Git-Tag: v4.7~112 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b6f80ea9f54b75eac68bb07d6b1079bc4b7db172;p=thirdparty%2Fccache.git refactor: Use new util::Blob typedef --- diff --git a/src/AtomicFile.cpp b/src/AtomicFile.cpp index f85957379..9585df816 100644 --- a/src/AtomicFile.cpp +++ b/src/AtomicFile.cpp @@ -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& data) +AtomicFile::write(const util::Blob& data) { if (fwrite(data.data(), data.size(), 1, m_stream) != 1) { throw core::Error( diff --git a/src/AtomicFile.hpp b/src/AtomicFile.hpp index 9dba4181f..2dffb25ff 100644 --- a/src/AtomicFile.hpp +++ b/src/AtomicFile.hpp @@ -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. // @@ -18,10 +18,11 @@ #pragma once +#include + #include #include #include -#include // 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& 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 diff --git a/unittest/test_AtomicFile.cpp b/unittest/test_AtomicFile.cpp index 7ac1dbfa9..a572040c4 100644 --- a/unittest/test_AtomicFile.cpp +++ b/unittest/test_AtomicFile.cpp @@ -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{0x65, 0x6c}); + atomic_file.write(util::Blob{0x65, 0x6c}); fputs("lo", atomic_file.stream()); atomic_file.commit(); CHECK(Util::read_file("test") == "hello");