1
0

write shit

This commit is contained in:
2025-11-27 14:15:20 +08:00
parent ac42f426f0
commit 9b28306597
7 changed files with 168 additions and 4 deletions

View File

@@ -0,0 +1,30 @@
#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