Skip to content

Commit

Permalink
fix: fix dll deps load
Browse files Browse the repository at this point in the history
  • Loading branch information
OEOTYAN committed Jan 28, 2024
1 parent cf59292 commit 98e32e1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/ll/api/data/KeyValueDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ KeyValueDB::KeyValueDB(std::filesystem::path const& path, bool createIfMiss, int
std::error_code ec;
std::filesystem::create_directories(path, ec);
}
impl = std::make_unique<KeyValueDBImpl>(string_utils::wstr2str(path.native()), createIfMiss, bloomFilterBit);
impl = std::make_unique<KeyValueDBImpl>(string_utils::wstr2str(path.wstring()), createIfMiss, bloomFilterBit);
}

KeyValueDB::KeyValueDB(KeyValueDB&&) noexcept = default;
Expand Down
2 changes: 1 addition & 1 deletion src/ll/api/io/FileUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ data::Version getVersion(std::filesystem::path const& filePath) {
data::Version version;
ushort build_ver{};
uint flag{};
if (!getFileVersion(filePath.native(), version.major, version.minor, version.patch, build_ver, flag)) {
if (!getFileVersion(filePath.wstring(), version.major, version.minor, version.patch, build_ver, flag)) {
return {};
} else {
version.preRelease = data::PreRelease{};
Expand Down
20 changes: 16 additions & 4 deletions src/ll/core/plugin/NativePluginManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ NativePluginManager::NativePluginManager() : PluginManager(NativePluginManagerNa
NativePluginManager::~NativePluginManager() = default;

static void printDependencyError(
const std::unique_ptr<pl::dependency_walker::DependencyIssueItem>& item,
std::unique_ptr<pl::dependency_walker::DependencyIssueItem> const& item,
std::ostream& stream,
size_t depth = 0
) {
Expand All @@ -39,14 +39,14 @@ static void printDependencyError(
}
}
if (!item->mDependencies.empty()) {
for (const auto& [module, subItem] : item->mDependencies) {
for (auto const& [module, subItem] : item->mDependencies) {
printDependencyError(subItem, stream, depth + 1);
}
}
}
}

std::string diagnosticDependency(const std::filesystem::path& path) {
static std::string diagnosticDependency(std::filesystem::path const& path) {
auto result = pl::dependency_walker::pl_diagnostic_dependency(path);
std::stringstream stream;
printDependencyError(result, stream);
Expand All @@ -58,7 +58,19 @@ bool NativePluginManager::load(Manifest manifest) {
if (hasPlugin(manifest.name)) {
return false;
}
auto entry = getPluginsRoot() / manifest.name / manifest.entry;
auto pluginDir = std::filesystem::canonical(getPluginsRoot() / manifest.name);

std::wstring buffer(32767, '\0');

if (auto res = GetEnvironmentVariable(L"PATH", buffer.data(), 32767); res != 0 && res != 32767) {
buffer.resize(res);
if (!buffer.empty()) {
buffer += L";";
}
buffer += pluginDir.wstring();
SetEnvironmentVariable(L"PATH", buffer.c_str());
}
auto entry = pluginDir / manifest.entry;
auto lib = LoadLibrary(entry.c_str());
if (!lib) {
auto e = error_utils::getWinLastError();
Expand Down

0 comments on commit 98e32e1

Please sign in to comment.