-// 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.
//
}
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(
-// 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.
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
-// 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.
//
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");