Changed DynLib internal

Fixes the "Assimp32.dll not found" bug


Former-commit-id: 662adba33c5d9cfbd23c8b0af0670626070baaa9
This commit is contained in:
Lynix
2014-01-12 10:33:03 +01:00
parent 6545b919c5
commit 9389e1ea05
7 changed files with 21 additions and 22 deletions

View File

@@ -8,12 +8,12 @@
#include <Nazara/Core/String.hpp>
#include <Nazara/Core/Debug.hpp>
NzDynLibImpl::NzDynLibImpl(NzDynLib* parent) :
m_parent(parent)
NzDynLibImpl::NzDynLibImpl(NzDynLib* parent)
{
NazaraUnused(parent);
}
NzDynLibFunc NzDynLibImpl::GetSymbol(const NzString& symbol) const
NzDynLibFunc NzDynLibImpl::GetSymbol(const NzString& symbol, NzString* errorMessage) const
{
/*
Il n'est pas standard de cast un pointeur d'objet vers un pointeur de fonction.
@@ -31,26 +31,27 @@ NzDynLibFunc NzDynLibImpl::GetSymbol(const NzString& symbol) const
converter.pointer = dlsym(m_handle, symbol.GetConstBuffer());
if (!converter.pointer)
m_parent->SetLastError(dlerror());
*errorMessage = dlerror();
return converter.func;
}
bool NzDynLibImpl::Load(const NzString& libraryPath)
bool NzDynLibImpl::Load(const NzString& libraryPath, NzString* errorMessage)
{
NzString path = libraryPath;
if (!path.EndsWith(".so"))
unsigned int pos = path.FindLast(".so");
if (pos == NzString::npos || (path.GetLength() > pos+3 && path[pos+3] != '.'))
path += ".so";
dlerror(); // Clear error flag
m_handle = dlopen(path.GetConstBuffer(), RTLD_LAZY | RTLD_GLOBAL);
if (m_handle)
return true;
else
{
m_parent->SetLastError(dlerror());
*errorMessage = dlerror();
return false;
}
}

View File

@@ -25,7 +25,6 @@ class NzDynLibImpl : NzNonCopyable
private:
void* m_handle;
NzDynLib* m_parent;
};
#endif // NAZARA_DYNLIBIMPL_HPP