| @@ -42,6 +42,9 @@ | |||||
| #include <aeffect.h> | #include <aeffect.h> | ||||
| #include <aeffectx.h> | #include <aeffectx.h> | ||||
| #include <stdio.h> | #include <stdio.h> | ||||
| #ifdef HAVE_UNIX | |||||
| #include <unistd.h> | |||||
| #endif | |||||
| #include "../dep/yac/yac.h" | #include "../dep/yac/yac.h" | ||||
| #include "../dep/yac/yac_host.cpp" | #include "../dep/yac/yac_host.cpp" | ||||
| @@ -523,15 +526,26 @@ public: | |||||
| char oldCWD[1024]; | char oldCWD[1024]; | ||||
| char dllnameraw[1024]; | char dllnameraw[1024]; | ||||
| #ifdef HAVE_WINDOWS | |||||
| ::GetCurrentDirectory(1024, (LPSTR) oldCWD); | ::GetCurrentDirectory(1024, (LPSTR) oldCWD); | ||||
| // ::GetModuleFileNameA(NULL, dllnameraw, 1024); // returns executable name (not the dll pathname) | // ::GetModuleFileNameA(NULL, dllnameraw, 1024); // returns executable name (not the dll pathname) | ||||
| GetModuleFileNameA((HINSTANCE)&__ImageBase, dllnameraw, 1024); | GetModuleFileNameA((HINSTANCE)&__ImageBase, dllnameraw, 1024); | ||||
| #elif defined(HAVE_UNIX) | |||||
| getcwd(oldCWD, 1024); | |||||
| readlink("/proc/self/exe", dllnameraw, 1024); | |||||
| #endif | |||||
| dllname.visit(dllnameraw); | dllname.visit(dllnameraw); | ||||
| dllname.getDirName(&cwd); | dllname.getDirName(&cwd); | ||||
| rack::global->vst2.program_dir = (const char*)cwd.chars; | rack::global->vst2.program_dir = (const char*)cwd.chars; | ||||
| Dprintf("xxx vstrack_plugin::openEffect: cd to \"%s\"\n", (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); | ::SetCurrentDirectory((const char*)cwd.chars); | ||||
| #elif defined(HAVE_UNIX) | |||||
| chdir((const char*)cwd.chars); | |||||
| #endif | |||||
| Dprintf("xxx vstrack_plugin::openEffect: cwd change done\n"); | Dprintf("xxx vstrack_plugin::openEffect: cwd change done\n"); | ||||
| // cwd.replace('\\', '/'); | // cwd.replace('\\', '/'); | ||||
| @@ -552,7 +566,12 @@ public: | |||||
| vst2_set_shared_plugin_tls_globals(); | vst2_set_shared_plugin_tls_globals(); | ||||
| Dprintf("xxx vstrack_plugin::openEffect: restore cwd=\"%s\"\n", oldCWD); | Dprintf("xxx vstrack_plugin::openEffect: restore cwd=\"%s\"\n", oldCWD); | ||||
| #ifdef HAVE_WINDOWS | |||||
| ::SetCurrentDirectory(oldCWD); | ::SetCurrentDirectory(oldCWD); | ||||
| #elif defined(HAVE_UNIX) | |||||
| chdir(oldCWD); | |||||
| #endif | |||||
| setSampleRate(sample_rate); | setSampleRate(sample_rate); | ||||