31 lines
789 B
C++
31 lines
789 B
C++
#include "dll_loader.hpp"
|
|
#include <stdexcept>
|
|
|
|
namespace Basalt::Presenter {
|
|
|
|
DllLoader::DllLoader(DllKind kind, const std::basic_string_view<BSCHAR> filename) {
|
|
// TODO:
|
|
// Add current executable location supports.
|
|
// Add sub directories supports.
|
|
// Fix file name terminal error.
|
|
#if defined(BASALT_OS_WINDOWS)
|
|
m_Handle = LoadLibraryW(filename.data());
|
|
#else
|
|
m_Handle = dlopen(filename.data(), RTLD_LAZY);
|
|
#endif
|
|
if (!m_Handle)
|
|
throw std::runtime_error("can not load given dynamic library.");
|
|
}
|
|
|
|
DllLoader::~DllLoader() {
|
|
if (m_Handle) {
|
|
#if defined(BASALT_OS_WINDOWS)
|
|
FreeLibrary(m_Handle);
|
|
#else
|
|
dlclose(m_Handle);
|
|
#endif
|
|
}
|
|
}
|
|
|
|
} // namespace Basalt::Presenter
|