Skip to content

Commit

Permalink
Add get_lib_name()
Browse files Browse the repository at this point in the history
  • Loading branch information
falkTX committed Sep 7, 2019
1 parent e5b1716 commit d8be5a9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/loadlib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ VstVoidFunc x_dlfunc (void* handle, const char* symbol)
#endif
}

static char libname[1024] = "";
static char libpath[1024] = "";

#ifdef WIN32
Expand All @@ -91,6 +92,11 @@ BOOL WINAPI DllMain (HINSTANCE handle, DWORD fdwReason, LPVOID lpvReserved)
{
if (fdwReason == 1) {
GetModuleFileNameA (handle, libpath, 1024);

strcpy (libname, libpath);
char* dot = strrchr (libname, '.');
if (dot) { *dot = 0; }

char* sep = strrchr (libpath, '\\');
if (sep) { *sep = 0; }
}
Expand All @@ -105,11 +111,20 @@ static void on_load(void) {
dladdr ((void *)on_load, &dl_info);
strncpy (libpath, dl_info.dli_fname, 1024);
libpath[1023] = 0;

strcpy (libname, libpath);
char* dot = strrchr (libname, '.');
if (dot) { *dot = 0; }

char* sep = strrchr (libpath, '/');
if (sep) { *sep = 0; }
}
#endif

const char* get_lib_name () {
return libname;
}

const char* get_lib_path () {
return libpath;
}
1 change: 1 addition & 0 deletions src/loadlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ VstVoidFunc x_dlfunc (void* handle, const char* symbol);
void* open_lv2_lib (const char* lib_path, bool persist = false);
void close_lv2_lib (void*);

const char* get_lib_name ();
const char* get_lib_path ();
#endif

0 comments on commit d8be5a9

Please sign in to comment.