Q-W1 pt1: extract core/json (json::Reader/Writer), collapse wire Cursor family into core/wire, shared readFileBytes — five JSON decoders and three cursor copies deleted, byte-identical formats, 59/59 green
This commit is contained in:
+4
-14
@@ -43,6 +43,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "capture_paths.h"
|
||||
#include "core/util/file_bytes.h"
|
||||
#include "render_settings.h"
|
||||
|
||||
#define REAPERAPI_MINIMAL
|
||||
@@ -226,20 +227,9 @@ std::string makeUniqueTag() {
|
||||
return std::to_string(static_cast<long long>(now));
|
||||
}
|
||||
|
||||
// Reads the whole file into a byte buffer. Returns an empty vector on any I/O
|
||||
// failure (the caller then leaves contentHash empty — the safe, confirm-eliciting
|
||||
// direction for an unreadable file).
|
||||
std::vector<std::uint8_t> readFileBytes(const std::string& path) {
|
||||
std::ifstream f(path, std::ios::binary | std::ios::ate);
|
||||
if (!f) return {};
|
||||
const std::streamoff size = f.tellg();
|
||||
if (size <= 0) return {};
|
||||
std::vector<std::uint8_t> bytes(static_cast<std::size_t>(size));
|
||||
f.seekg(0);
|
||||
f.read(reinterpret_cast<char*>(bytes.data()), size);
|
||||
if (!f) return {};
|
||||
return bytes;
|
||||
}
|
||||
// Whole-file reads go through the shared core/util readFileBytes (Q-W1, T2-03):
|
||||
// empty on any I/O failure (the caller then leaves contentHash empty — the safe,
|
||||
// confirm-eliciting direction for an unreadable file).
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
Reference in New Issue
Block a user