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