// 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 #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 buf(4096, '\0'); ReaProject* const active = EnumProjects(-1, buf.data(), static_cast(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(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