update boost
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// Copyright 2014 Renato Tegon Forti, Antony Polukhin.
|
||||
// Copyright 2015-2019 Antony Polukhin.
|
||||
// Copyright Antony Polukhin, 2015-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt
|
||||
@@ -31,27 +31,28 @@ namespace boost { namespace dll { namespace detail {
|
||||
BOOST_STATIC_CONSTANT(boost::winapi::DWORD_, ERROR_INSUFFICIENT_BUFFER_ = 0x7A);
|
||||
BOOST_STATIC_CONSTANT(boost::winapi::DWORD_, DEFAULT_PATH_SIZE_ = 260);
|
||||
|
||||
// On success, GetModuleFileNameW() doesn't reset last error to ERROR_SUCCESS. Resetting it manually.
|
||||
boost::winapi::GetLastError();
|
||||
|
||||
// If `handle` parameter is NULL, GetModuleFileName retrieves the path of the
|
||||
// executable file of the current process.
|
||||
boost::winapi::WCHAR_ path_hldr[DEFAULT_PATH_SIZE_];
|
||||
boost::winapi::GetModuleFileNameW(handle, path_hldr, DEFAULT_PATH_SIZE_);
|
||||
ec = boost::dll::detail::last_error_code();
|
||||
if (!ec) {
|
||||
const boost::winapi::DWORD_ ret = boost::winapi::GetModuleFileNameW(handle, path_hldr, DEFAULT_PATH_SIZE_);
|
||||
if (ret) {
|
||||
// On success, GetModuleFileNameW() doesn't reset last error to ERROR_SUCCESS. Resetting it manually.
|
||||
ec.clear();
|
||||
return boost::dll::fs::path(path_hldr);
|
||||
}
|
||||
|
||||
ec = boost::dll::detail::last_error_code();
|
||||
for (unsigned i = 2; i < 1025 && static_cast<boost::winapi::DWORD_>(ec.value()) == ERROR_INSUFFICIENT_BUFFER_; i *= 2) {
|
||||
std::wstring p(DEFAULT_PATH_SIZE_ * i, L'\0');
|
||||
const std::size_t size = boost::winapi::GetModuleFileNameW(handle, &p[0], DEFAULT_PATH_SIZE_ * i);
|
||||
ec = boost::dll::detail::last_error_code();
|
||||
|
||||
if (!ec) {
|
||||
if (size) {
|
||||
// On success, GetModuleFileNameW() doesn't reset last error to ERROR_SUCCESS. Resetting it manually.
|
||||
ec.clear();
|
||||
p.resize(size);
|
||||
return boost::dll::fs::path(p);
|
||||
}
|
||||
|
||||
ec = boost::dll::detail::last_error_code();
|
||||
}
|
||||
|
||||
// Error other than ERROR_INSUFFICIENT_BUFFER_ occurred or failed to allocate buffer big enough.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Copyright 2014 Renato Tegon Forti, Antony Polukhin.
|
||||
// Copyright 2015-2019 Antony Polukhin.
|
||||
// Copyright Antony Polukhin, 2015-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt
|
||||
@@ -56,11 +56,12 @@ public:
|
||||
return actual_path;
|
||||
}
|
||||
|
||||
void load(boost::dll::fs::path sl, load_mode::type mode, boost::dll::fs::error_code &ec) {
|
||||
void load(boost::dll::fs::path sl, load_mode::type portable_mode, boost::dll::fs::error_code &ec) {
|
||||
typedef boost::winapi::DWORD_ native_mode_t;
|
||||
native_mode_t native_mode = static_cast<native_mode_t>(portable_mode);
|
||||
unload();
|
||||
|
||||
if (!sl.is_absolute() && !(mode & load_mode::search_system_folders)) {
|
||||
if (!sl.is_absolute() && !(native_mode & load_mode::search_system_folders)) {
|
||||
boost::dll::fs::error_code current_path_ec;
|
||||
boost::dll::fs::path prog_loc = boost::dll::fs::current_path(current_path_ec);
|
||||
|
||||
@@ -69,13 +70,13 @@ public:
|
||||
sl.swap(prog_loc);
|
||||
}
|
||||
}
|
||||
mode &= ~load_mode::search_system_folders;
|
||||
native_mode = static_cast<unsigned>(native_mode) & ~static_cast<unsigned>(load_mode::search_system_folders);
|
||||
|
||||
// Trying to open with appended decorations
|
||||
if (!!(mode & load_mode::append_decorations)) {
|
||||
mode &= ~load_mode::append_decorations;
|
||||
if (!!(native_mode & load_mode::append_decorations)) {
|
||||
native_mode = static_cast<unsigned>(native_mode) & ~static_cast<unsigned>(load_mode::append_decorations);
|
||||
|
||||
if (load_impl(decorate(sl), static_cast<native_mode_t>(mode), ec)) {
|
||||
if (load_impl(decorate(sl), native_mode, ec)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -85,7 +86,7 @@ public:
|
||||
? sl.parent_path() / L"lib"
|
||||
: L"lib"
|
||||
).native() + sl.filename().native() + suffix().native();
|
||||
if (load_impl(mingw_load_path, static_cast<native_mode_t>(mode), ec)) {
|
||||
if (load_impl(mingw_load_path, native_mode, ec)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -98,9 +99,9 @@ public:
|
||||
// we have some path. So we do not check for path, only for extension. We can not be sure that
|
||||
// such behavior remain across all platforms, so we add L"." by hand.
|
||||
if (sl.has_extension()) {
|
||||
handle_ = boost::winapi::LoadLibraryExW(sl.c_str(), 0, static_cast<native_mode_t>(mode));
|
||||
handle_ = boost::winapi::LoadLibraryExW(sl.c_str(), 0, native_mode);
|
||||
} else {
|
||||
handle_ = boost::winapi::LoadLibraryExW((sl.native() + L".").c_str(), 0, static_cast<native_mode_t>(mode));
|
||||
handle_ = boost::winapi::LoadLibraryExW((sl.native() + L".").c_str(), 0, native_mode);
|
||||
}
|
||||
|
||||
// LoadLibraryExW method is capable of self loading from program_location() path. No special actions
|
||||
|
||||
Reference in New Issue
Block a user