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:
2026-07-28 19:59:02 -04:00
parent 88e7765ee5
commit 67a41728f3
25 changed files with 1695 additions and 1696 deletions
+3 -13
View File
@@ -22,6 +22,7 @@
#include "bank_model.h" // Sample, AddResult, findByHash
#include "bank_panel.h" // bankPanelRefresh
#include "capture_paths.h" // deriveBankPaths / projectDirOfRpp / hashWavContent
#include "core/util/file_bytes.h" // shared whole-file loader (Q-W1, T2-03)
#include "instrument_drop.h" // pure buildInstrumentDropPreset (.vstpreset image for a sampleId)
#include "instrument_drop_win.h" // shell loadInstrumentOntoTrack (FX add+apply, no own undo block)
#include "persist.h" // ReaSamplerSession
@@ -81,19 +82,8 @@ std::string currentProjectDir() {
return projectDirOfRpp(std::string(buf.data()));
}
// Reads a whole file's bytes. Empty vector on any failure (missing / unreadable). Mirror
// of capture.cpp's readFileBytes — used to read the source and validate/hash the bank copy.
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::streamsize n = f.tellg();
if (n <= 0) return {};
std::vector<std::uint8_t> bytes(static_cast<std::size_t>(n));
f.seekg(0);
f.read(reinterpret_cast<char*>(bytes.data()), n);
if (!f) return {};
return bytes;
}
// Whole-file reads (source read + bank-copy validate/hash) go through the shared
// core/util readFileBytes (Q-W1, T2-03): empty on any failure (missing / unreadable).
// Writes a byte buffer to a file. Returns true on success. The caller is responsible for
// ensuring the directory exists before calling.