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
+4 -12
View File
@@ -17,10 +17,11 @@
#include "core/model/bank_book.h" // BankBook, Bank, activeBankId / activeIndex
#include "core/model/bank_model.h" // Sample, AddResult, findByHash
#include "shell/panel/panel_input.h" // bankPanelRefresh
#include "core/capture/capture_paths.h" // deriveBankPaths / projectDirOfRpp
#include "core/capture/capture_paths.h" // deriveBankPaths
#include "core/util/file_bytes.h" // shared whole-file loader
#include "core/wire/instrument_drop.h" // pure buildInstrumentDropPreset (.vstpreset image for a sampleId)
#include "shell/actions/instrument_drop_win.h" // shell loadInstrumentOntoTrack (FX add+apply, no own undo block)
#include "shell/persist/bank_root.h"
#include "shell/persist/session.h" // ReaSamplerSession
#include "shell/undo/undo_block.h" // the ONE undo-block opener
@@ -29,7 +30,6 @@
#include "reaper_plugin.h" // reaper_plugin_info_t, gaccel_register_t (full defs)
#define REAPERAPI_MINIMAL
#define REAPERAPI_WANT_EnumProjects
#define REAPERAPI_WANT_ShowConsoleMsg
#define REAPERAPI_WANT_MediaExplorerGetLastPlayedFileInfo
#define REAPERAPI_WANT_PCM_Source_CreateFromFile
@@ -47,7 +47,6 @@ using capture::buildFloat32Wav;
using capture::deriveBankPaths;
using capture::hashWavContent;
using capture::parseWavLayout;
using capture::projectDirOfRpp;
using capture::WavLayout;
using util::readFileBytes;
using version::channelActionName;
@@ -79,14 +78,6 @@ std::string g_idImportStr;
std::string g_idImportMxStr;
std::string g_labelImportStr;
// Forward-slashed, no trailing slash. Empty for an unsaved/no-active project, which
// makes the import refuse to place a file (relative-paths invariant, no fallback).
std::string currentProjectDir() {
std::vector<char> buf(4096, '\0');
EnumProjects(-1, buf.data(), static_cast<int>(buf.size()));
return projectDirOfRpp(std::string(buf.data()));
}
// Writes a byte buffer to a file. Returns true on success. The caller is responsible for
// ensuring the directory exists before calling.
bool writeFileBytes(const std::string& path, const std::vector<std::uint8_t>& bytes) {
@@ -170,7 +161,8 @@ ImportResult importFileIntoActiveBank(const std::string& absoluteSourcePath) {
return out;
}
const std::string projectDir = currentProjectDir();
// Empty refuses to place a file: relative-paths invariant, no fallback.
const std::string projectDir = bankRootOf(nullptr);
if (projectDir.empty()) {
out.message = "no saved project, so the bank has no location -- save the "
"project first";
+3 -9
View File
@@ -9,13 +9,13 @@
#include <string>
#include <vector>
#include "core/capture/capture_paths.h" // projectDirOfRpp, sanitizeStem
#include "core/capture/capture_paths.h" // sanitizeStem
#include "shell/package/export_bank.h"
#include "shell/package/package_pickers.h"
#include "shell/persist/bank_root.h"
#include "shell/persist/session.h"
#define REAPERAPI_MINIMAL
#define REAPERAPI_WANT_EnumProjects
#define REAPERAPI_WANT_ShowConsoleMsg
#define REAPERAPI_WANT_ShowMessageBox
#include "reaper_plugin_functions.h"
@@ -28,12 +28,6 @@ constexpr const char* kUnsavedProjectMsg =
"ReaSampler export: save the project first -- an unsaved project has no bank folder "
"to read from.\n";
std::string currentProjectDir() {
std::vector<char> buf(4096, '\0');
EnumProjects(-1, buf.data(), static_cast<int>(buf.size()));
return capture::projectDirOfRpp(std::string(buf.data()));
}
// 6 == YES; anything else cancels (SDK ~6544).
bool confirmed(const std::string& msg, const char* title) {
return ShowMessageBox(msg.c_str(), title, 4) == 6;
@@ -118,7 +112,7 @@ void reportOutcome(const ExportOutcome& out, const std::string& destPath) {
} // namespace
void doBankPackageExport(const ReaSamplerSession& session, const std::string& bankId) {
const std::string projectDir = currentProjectDir();
const std::string projectDir = bankRootOf(nullptr);
if (projectDir.empty()) {
ShowConsoleMsg(kUnsavedProjectMsg);
return;