Added similar python plugin improvements for Windows
parent
d161aa6490
commit
5e151f3bac
|
@ -1,4 +1,5 @@
|
||||||
#include <mitsuba/core/fresolver.h>
|
#include <mitsuba/core/fresolver.h>
|
||||||
|
#include <boost/algorithm/string.hpp>
|
||||||
|
|
||||||
#if defined(__WINDOWS__)
|
#if defined(__WINDOWS__)
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
|
@ -47,9 +48,10 @@ FileResolver::FileResolver() {
|
||||||
|
|
||||||
// There is an error if and only if the function returns 0
|
// There is an error if and only if the function returns 0
|
||||||
if (nSize != 0) {
|
if (nSize != 0) {
|
||||||
prependPath(fs::path(lpFilename).parent_path());
|
fs::path path(lpFilename);
|
||||||
}
|
if (boost::to_lower_copy(path.filename().string()).find("python") == std::string::npos)
|
||||||
else {
|
prependPath(path.parent_path());
|
||||||
|
} else {
|
||||||
const std::string msg(lastErrorText());
|
const std::string msg(lastErrorText());
|
||||||
Log(EError, "Could not detect the executable path! (%s)", msg.c_str());
|
Log(EError, "Could not detect the executable path! (%s)", msg.c_str());
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
# include <dlfcn.h>
|
# include <dlfcn.h>
|
||||||
#elif defined(__OSX__)
|
#elif defined(__OSX__)
|
||||||
# include <mach-o/dyld.h>
|
# include <mach-o/dyld.h>
|
||||||
|
#elif defined(__WINDOWS__)
|
||||||
|
# include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace mitsuba;
|
using namespace mitsuba;
|
||||||
|
@ -71,6 +73,25 @@ void initializeFramework() {
|
||||||
if (boost::ends_with(imageName, "mitsuba.so"))
|
if (boost::ends_with(imageName, "mitsuba.so"))
|
||||||
basePath = fs::path(imageName).parent_path().parent_path().parent_path();
|
basePath = fs::path(imageName).parent_path().parent_path().parent_path();
|
||||||
}
|
}
|
||||||
|
#elif defined(__WINDOWS__)
|
||||||
|
HMODULE hm;
|
||||||
|
std::vector<WCHAR> lpFilename(MAX_PATH);
|
||||||
|
if (GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
|
||||||
|
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCSTR) &initializeFramework, &hm)) {
|
||||||
|
std::vector<WCHAR> lpFilename(MAX_PATH);
|
||||||
|
|
||||||
|
// Try to get the path with the default MAX_PATH length (260 chars)
|
||||||
|
DWORD nSize = GetModuleFileNameW(hm, &lpFilename[0], MAX_PATH);
|
||||||
|
|
||||||
|
// Adjust the buffer size in case if was too short
|
||||||
|
while (nSize == lpFilename.size()) {
|
||||||
|
lpFilename.resize(nSize * 2);
|
||||||
|
nSize = GetModuleFileNameW(hm, &lpFilename[0], nSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nSize)
|
||||||
|
basePath = fs::path(lpFilename).parent_path().parent_path().parent_path();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!basePath.empty())
|
if (!basePath.empty())
|
||||||
|
|
Loading…
Reference in New Issue