fixed relative path issues when dlopen is being called
This commit is contained in:
parent
007fe5999e
commit
ede7b63e46
|
@ -5,6 +5,7 @@
|
|||
#else
|
||||
#include <dlfcn.h>
|
||||
#include "extil.h"
|
||||
#include <libgen.h>
|
||||
static void* devILhandle;
|
||||
#endif
|
||||
|
||||
|
@ -69,10 +70,18 @@ bool extil_Open(JNIEnv *env, jobjectArray ilPaths) {
|
|||
#ifdef _WIN32
|
||||
devILhandle = LoadLibrary(path_str);
|
||||
#else
|
||||
devILhandle = dlopen(path_str, RTLD_LAZY);
|
||||
if(devILhandle == NULL) {
|
||||
printfDebug("dlopen failure: %s", dlerror());
|
||||
char* directoryName = dirname(path_str);
|
||||
char* fileName = basename(path_str);
|
||||
char* currentDirectory = getwd(NULL);
|
||||
if(directoryName != NULL) {
|
||||
chdir(directoryName);
|
||||
}
|
||||
devILhandle = dlopen(fileName, RTLD_LAZY);
|
||||
if(devILhandle == NULL) {
|
||||
printfDebug("dlopen failure: %s\n\n\n", dlerror());
|
||||
}
|
||||
chdir(currentDirectory);
|
||||
free(currentDirectory);
|
||||
#endif
|
||||
if (devILhandle != NULL) {
|
||||
printfDebug("Found devil at '%s'\n", path_str);
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#else
|
||||
#include <dlfcn.h>
|
||||
#include "extilu.h"
|
||||
#include <libgen.h>
|
||||
static void* devILUhandle;
|
||||
#endif
|
||||
|
||||
|
@ -58,10 +59,18 @@ bool extilu_Open(JNIEnv *env, jobjectArray ilPaths) {
|
|||
#ifdef _WIN32
|
||||
devILUhandle = LoadLibrary(path_str);
|
||||
#else
|
||||
devILUhandle = dlopen(path_str, RTLD_LAZY);
|
||||
if(devILUhandle == NULL) {
|
||||
printfDebug("dlopen failure: %s", dlerror());
|
||||
char* directoryName = dirname(path_str);
|
||||
char* fileName = basename(path_str);
|
||||
char* currentDirectory = getwd(NULL);
|
||||
if(directoryName != NULL) {
|
||||
chdir(directoryName);
|
||||
}
|
||||
devILUhandle = dlopen(fileName, RTLD_LAZY);
|
||||
if(devILUhandle == NULL) {
|
||||
printfDebug("dlopen failure: %s\n\n\n", dlerror());
|
||||
}
|
||||
chdir(currentDirectory);
|
||||
free(currentDirectory);
|
||||
#endif
|
||||
if (devILUhandle != NULL) {
|
||||
printfDebug("Found ilu at '%s'\n", path_str);
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#else
|
||||
#include <dlfcn.h>
|
||||
#include "extilut.h"
|
||||
#include <libgen.h>
|
||||
static void* devILUThandle;
|
||||
#endif
|
||||
|
||||
|
@ -58,10 +59,18 @@ bool extilut_Open(JNIEnv *env, jobjectArray ilPaths) {
|
|||
#ifdef _WIN32
|
||||
devILUThandle = LoadLibrary(path_str);
|
||||
#else
|
||||
devILUThandle = dlopen(path_str, RTLD_LAZY);
|
||||
if(devILUThandle == NULL) {
|
||||
printfDebug("dlopen failure: %s", dlerror());
|
||||
char* directoryName = dirname(path_str);
|
||||
char* fileName = basename(path_str);
|
||||
char* currentDirectory = getwd(NULL);
|
||||
if(directoryName != NULL) {
|
||||
chdir(directoryName);
|
||||
}
|
||||
devILUThandle = dlopen(fileName, RTLD_LAZY);
|
||||
if(devILUThandle == NULL) {
|
||||
printfDebug("dlopen failure: %s\n\n\n", dlerror());
|
||||
}
|
||||
chdir(currentDirectory);
|
||||
free(currentDirectory);
|
||||
#endif
|
||||
if (devILUThandle != NULL) {
|
||||
printfDebug("Found ilut at '%s'\n", path_str);
|
||||
|
|
Loading…
Reference in New Issue