From e8a70c9ba487c555a99329638d2c125d4d3b2cbf Mon Sep 17 00:00:00 2001 From: Cameron Leger Date: Wed, 10 Oct 2018 18:33:17 -0600 Subject: [PATCH 1/2] Cross-platform vst2_main directory changes --- src/vst2_main.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/vst2_main.cpp b/src/vst2_main.cpp index 8565b6ab..208cc5f9 100644 --- a/src/vst2_main.cpp +++ b/src/vst2_main.cpp @@ -42,6 +42,9 @@ #include #include #include +#ifdef HAVE_UNIX +#include +#endif #include "../dep/yac/yac.h" #include "../dep/yac/yac_host.cpp" @@ -523,15 +526,26 @@ public: char oldCWD[1024]; char dllnameraw[1024]; + +#ifdef HAVE_WINDOWS ::GetCurrentDirectory(1024, (LPSTR) oldCWD); // ::GetModuleFileNameA(NULL, dllnameraw, 1024); // returns executable name (not the dll pathname) GetModuleFileNameA((HINSTANCE)&__ImageBase, dllnameraw, 1024); +#elif defined(HAVE_UNIX) + getcwd(oldCWD, 1024); + readlink("/proc/self/exe", dllnameraw, 1024); +#endif + dllname.visit(dllnameraw); dllname.getDirName(&cwd); rack::global->vst2.program_dir = (const char*)cwd.chars; + Dprintf("xxx vstrack_plugin::openEffect: cd to \"%s\"\n", (const char*)cwd.chars); - // // ::SetCurrentDirectory("f:/vst_64bit/vstrack_plugin"); +#ifdef HAVE_WINDOWS ::SetCurrentDirectory((const char*)cwd.chars); +#elif defined(HAVE_UNIX) + chdir((const char*)cwd.chars); +#endif Dprintf("xxx vstrack_plugin::openEffect: cwd change done\n"); // cwd.replace('\\', '/'); @@ -552,7 +566,12 @@ public: vst2_set_shared_plugin_tls_globals(); Dprintf("xxx vstrack_plugin::openEffect: restore cwd=\"%s\"\n", oldCWD); + +#ifdef HAVE_WINDOWS ::SetCurrentDirectory(oldCWD); +#elif defined(HAVE_UNIX) + chdir(oldCWD); +#endif setSampleRate(sample_rate); From 3e409c4b7891676f3c4e502544de1733123f9b7c Mon Sep 17 00:00:00 2001 From: Cameron Leger Date: Wed, 10 Oct 2018 18:36:51 -0600 Subject: [PATCH 2/2] Add one additional inline extern C issue --- src/vst2_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vst2_main.cpp b/src/vst2_main.cpp index 208cc5f9..b95c9583 100644 --- a/src/vst2_main.cpp +++ b/src/vst2_main.cpp @@ -85,7 +85,7 @@ extern void vst2_handle_queued_params (void); extern float vst2_get_param (int uniqueParamId); extern void vst2_get_param_name (int uniqueParamId, char *s, int sMaxLen); extern void vst2_set_shared_plugin_tls_globals (void); // see plugin.cpp -extern "C" extern int vst2_handle_effeditkeydown (unsigned int _vkey); +extern "C" { int vst2_handle_effeditkeydown (unsigned int _vkey); } namespace rack { extern bool b_touchkeyboard_enable;