Fixed extensions loading on Windows (#21355)

This commit is contained in:
Ilya Lavrenov 2023-11-29 12:40:42 +04:00 committed by GitHub
parent 39ba1ed03f
commit d553d4cd55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 10 deletions

View File

@ -95,7 +95,7 @@ std::wstring string_to_wstring(const std::string& str);
/// \brief Remove path components which would allow traversing up a directory tree.
/// \param path A path to file
/// \return A sanitiazed path
/// \return A sanitized path
std::string sanitize_path(const std::string& path);
/// \brief Returns the name with extension for a given path

View File

@ -92,15 +92,7 @@ std::shared_ptr<void> load_shared_object(const char* path) {
IEGetDllDirectoryA(nBufferLength, &lpBuffer.front());
// GetDirname
auto dirname = [path] {
auto pos = strchr(path, '\\');
if (pos == nullptr) {
return std::string{path};
}
std::string original(path);
original[pos - path] = 0;
return original;
}();
auto dirname = get_directory(path);
SetDllDirectoryA(dirname.c_str());
shared_object = LoadLibraryA(path);