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
+41
View File
@@ -0,0 +1,41 @@
// bank_root.cpp — see bank_root.h. main.cpp owns the API pointers; this TU gets them
// extern.
#include "shell/persist/bank_root.h"
#include <vector>
#include "core/capture/capture_paths.h" // bankRootFor
#define REAPERAPI_MINIMAL
#define REAPERAPI_WANT_EnumProjects
#include "reaper_plugin_functions.h"
namespace reasampler {
namespace {
// EnumProjects is the only SDK read of a project's .rpp path — GetProjectPathEx is the
// recording path, GetProjectName the bare file name. Empty for a never-saved project.
// The active project is read through idx -1 first, so the common case is one call.
std::string rppPathOf(ReaProject* proj) {
std::vector<char> buf(4096, '\0');
ReaProject* const active = EnumProjects(-1, buf.data(), static_cast<int>(buf.size()));
if (!proj || proj == active) return std::string(buf.data());
for (int idx = 0;; ++idx) {
buf[0] = '\0';
ReaProject* const tab = EnumProjects(idx, buf.data(), static_cast<int>(buf.size()));
if (!tab) return {}; // not an open tab: no location to answer with
if (tab == proj) return std::string(buf.data());
}
}
} // namespace
std::string bankRootOf(ReaProject* proj) {
// No unsaved root is supplied: a never-saved project has no bank location.
return capture::bankRootFor(rppPathOf(proj), std::string{});
}
} // namespace reasampler