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:
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user