Route every extension bank-directory lookup through one bankRootOf seam

The pure bankRootFor(rppPath, unsavedRoot) and the shell bankRootOf(ReaProject*) replace eleven hand-rolled .rpp-parent derivations. No unsaved root is supplied yet, so behaviour and refusals are unchanged. Save-As relocation now reads the stored lastBankRoot_.
This commit is contained in:
2026-09-25 14:53:48 -04:00
parent c3e7556261
commit 43994e0d9d
27 changed files with 212 additions and 192 deletions
+7 -22
View File
@@ -59,6 +59,7 @@
#include "core/capture/capture_realtime.h" // RecordPhase machine, record-mode plan (pure)
#include "core/capture/render_settings.h" // realtimeRecordWindowEnd
#include "shell/capture/capture_realtime_finalize.h" // recordedFilePath, finalizeRecording
#include "shell/persist/bank_root.h"
#define REAPERAPI_MINIMAL
#define REAPERAPI_WANT_EnumProjects
@@ -84,20 +85,6 @@ namespace reasampler::capture {
namespace {
std::string normSlashes(std::string s) {
for (char& c : s) if (c == '\\') c = '/';
if (s.size() > 1 && s.back() == '/') s.pop_back();
return s;
}
// Reads the ACTIVE project's .rpp path (empty if unsaved). Only needed at begin()
// time, when the record's project IS the active project.
std::string readRppPath() {
std::vector<char> buf(4096, '\0');
EnumProjects(-1, buf.data(), static_cast<int>(buf.size()));
return std::string(buf.data());
}
// -1 if unresolved yet. Used by the flush wait to detect stability (size
// unchanged across a tick) before moving the file — a take REAPER is still
// flushing grows tick over tick.
@@ -290,20 +277,18 @@ RealtimeRecordBackend::begin(const CaptureRequest& request,
return nullptr;
}
// Saved-project gate (same as offline): the bank folder resolves against the
// .rpp parent. Prompt Save-As once when unsaved; refuse if still unsaved.
std::string rppPath = readRppPath();
if (rppPath.empty()) {
// Bank-root gate (same as offline): prompt Save-As once when there is no bank
// root; refuse if there still is none.
std::string projectDir = bankRootOf(proj);
if (projectDir.empty()) {
Main_SaveProject(proj, true);
rppPath = readRppPath();
projectDir = bankRootOf(proj);
}
if (rppPath.empty()) {
if (projectDir.empty()) {
outFailure.status = CaptureStatus::NoProject;
outFailure.message = "Project must be saved before capture — nothing captured.";
return nullptr;
}
const std::string projectDir =
normSlashes(std::filesystem::path(rppPath).parent_path().string());
RealtimeCaptureHandle st(new RealtimeCaptureState());
st->proj_ = proj;