mirror of
https://github.com/Heretek-AI/GDevelop.git
synced 2026-07-22 10:05:37 -04:00
95c8dfaf62
git-svn-id: svn://localhost@972 8062f311-0dae-4547-b526-b8ab9ac864a5
51 lines
1.6 KiB
C++
51 lines
1.6 KiB
C++
/** \file
|
|
* Game Develop
|
|
* 2008-2013 Florian Rival (Florian.Rival@gmail.com)
|
|
*/
|
|
|
|
#if defined(WINDOWS)
|
|
#include <windows.h>
|
|
#include "GDCore/CommonTools.h"
|
|
#elif defined(LINUX) || defined (MAC)
|
|
#include <dlfcn.h>
|
|
#endif
|
|
#include <string>
|
|
#include "GDCore/Tools/DynamicLibrariesTools.h"
|
|
|
|
namespace gd
|
|
{
|
|
|
|
#if defined(WINDOWS)
|
|
Handle OpenLibrary(const char* path) {return LoadLibrary(path);}
|
|
void* GetSymbol(Handle library, const char* name) { return (void*)GetProcAddress(library, name);}
|
|
void CloseLibrary(Handle library) {FreeLibrary(library);}
|
|
std::string DynamicLibraryLastError()
|
|
{
|
|
LPSTR lpMsgBuf;
|
|
DWORD dw = GetLastError();
|
|
|
|
FormatMessage(
|
|
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
|
FORMAT_MESSAGE_FROM_SYSTEM |
|
|
FORMAT_MESSAGE_IGNORE_INSERTS,
|
|
NULL,
|
|
dw,
|
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
|
(LPTSTR) &lpMsgBuf,
|
|
0, NULL );
|
|
|
|
std::string errorMsg = "Error ("+ToString(dw)+"): "+std::string(lpMsgBuf);
|
|
return errorMsg;
|
|
}
|
|
#elif defined(LINUX) || defined (MAC)
|
|
Handle OpenLibrary(const char* path) {return dlopen(path, RTLD_LAZY);}
|
|
void* GetSymbol(Handle library, const char* name) { return dlsym(library, name);}
|
|
void CloseLibrary(Handle library) {dlclose(library);}
|
|
std::string DynamicLibraryLastError() {return std::string(dlerror());}
|
|
Handle SetLibraryGlobal(const char* path) {return dlopen(path, RTLD_NOLOAD|RTLD_GLOBAL);}
|
|
#else
|
|
#warning System not supported for dynamic libraries loading
|
|
#endif
|
|
|
|
}
|