commit 49b8ddd0a74f4370bfaa0a0b9fc7fa49b6d46413
parent c8a145bea3b6620ab1bd815566572442e1e6fc30
Author: cfillion <cfillion@users.noreply.github.com>
Date: Sun, 14 Feb 2016 21:26:31 -0800
ensure reapack is installed at the right location at startup
Diffstat:
2 files changed, 40 insertions(+), 1 deletion(-)
diff --git a/macosx.tup b/macosx.tup
@@ -8,7 +8,7 @@ CXXFLAGS += -Wno-unused-function
CXXFLAGS += -fdiagnostics-color -fstack-protector-strong -fvisibility=hidden
CXXFLAGS += -pipe -fPIC -O2 -std=c++14
CXXFLAGS += -Ivendor -Ivendor/WDL -Ivendor/WDL/WDL -Ivendor/WDL/WDL/swell
-CXXFLAGS += -DWDL_NO_DEFINE_MINMAX -DREAPACK_FILE=$(REAPACK_FILE)
+CXXFLAGS += -DWDL_NO_DEFINE_MINMAX -DREAPACK_FILE=\"$(REAPACK_FILE)\"
CXXFLAGS += -arch @(ARCH)
WDLFLAGS := -std=c++98 -w
diff --git a/src/main.cpp b/src/main.cpp
@@ -48,6 +48,7 @@ static bool loadAPI(void *(*getFunc)(const char *))
REQUIRED_API(RecursiveCreateDirectory), // v4.60
REQUIRED_API(ReverseNamedCommandLookup), // v4.7
REQUIRED_API(ShowMessageBox),
+ REQUIRED_API(Splash_GetWnd), // v4.7
OPTIONAL_API(AddRemoveReaScript), // v5.12
};
@@ -92,6 +93,41 @@ static void menuHook(const char *name, HMENU handle, int f)
NamedCommandLookup("_REAPACK_ABOUT"));
}
+static bool checkLocation(REAPER_PLUGIN_HINSTANCE module)
+{
+ Path expected;
+ expected.append(GetResourcePath());
+ expected.append("UserPlugins");
+ expected.append(REAPACK_FILE);
+
+#ifdef _WIN32
+ auto_char self[MAX_PATH] = {};
+ GetModuleFileName(module, self, sizeof(self));
+ Path current(from_autostring(self).c_str());
+#else
+ Dl_info info{};
+ dladdr((const void *)checkLocation, &info);
+ const char *self = info.dli_fname;
+ Path current(self);
+#endif
+
+ if(current == expected)
+ return true;
+
+ auto_char msg[4096] = {};
+ auto_snprintf(msg, sizeof(msg),
+ AUTO_STR("ReaPack was not loaded from the standard extension path")
+ AUTO_STR(" or its filename was altered.\n")
+ AUTO_STR("Move or rename it to the expected location and retry.\n\n")
+ AUTO_STR("Current:\xa0%s\n\nExpected:\xa0%s"),
+ self, make_autostring(expected.join()).c_str());
+
+ MessageBox(Splash_GetWnd(), msg,
+ AUTO_STR("ReaPack: Installation path mismatch"), MB_OK);
+
+ return false;
+}
+
extern "C" REAPER_PLUGIN_DLL_EXPORT int REAPER_PLUGIN_ENTRYPOINT(
REAPER_PLUGIN_HINSTANCE instance, reaper_plugin_info_t *rec)
{
@@ -110,6 +146,9 @@ extern "C" REAPER_PLUGIN_DLL_EXPORT int REAPER_PLUGIN_ENTRYPOINT(
if(!loadAPI(rec->GetFunc))
return 0;
+ if(!checkLocation(instance))
+ return 0;
+
reapack = new ReaPack(instance);
reapack->setupAction("REAPACK_SYNC", "ReaPack: Synchronize packages",