Browse Source

Cross-platform vst2_main directory changes

pull/1639/head
Cameron Leger 6 years ago
parent
commit
e8a70c9ba4
1 changed files with 20 additions and 1 deletions
  1. +20
    -1
      src/vst2_main.cpp

+ 20
- 1
src/vst2_main.cpp View File

@@ -42,6 +42,9 @@
#include <aeffect.h>
#include <aeffectx.h>
#include <stdio.h>
#ifdef HAVE_UNIX
#include <unistd.h>
#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);



Loading…
Cancel
Save