summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/PlatformUtils-win.cc16
-rw-r--r--src/PlatformUtils.cc9
2 files changed, 18 insertions, 7 deletions
diff --git a/src/PlatformUtils-win.cc b/src/PlatformUtils-win.cc
index a314ebe..a58a346 100644
--- a/src/PlatformUtils-win.cc
+++ b/src/PlatformUtils-win.cc
@@ -9,8 +9,6 @@
// convert from windows api w_char strings (usually utf16) to utf8 std::string
std::string winapi_wstr_to_utf8( std::wstring wstr )
{
- std::string utf8_str("");
-
UINT CodePage = CP_UTF8;
DWORD dwFlags = 0;
LPCWSTR lpWideCharStr = &wstr[0];
@@ -23,6 +21,9 @@ std::string winapi_wstr_to_utf8( std::wstring wstr )
int numbytes = WideCharToMultiByte( CodePage, dwFlags, lpWideCharStr,
cchWideChar, lpMultiByteStr, cbMultiByte, lpDefaultChar, lpUsedDefaultChar );
+ //PRINTB("utf16 to utf8 conversion: numbytes %i",numbytes);
+
+ std::string utf8_str(numbytes,0);
lpMultiByteStr = &utf8_str[0];
cbMultiByte = numbytes;
@@ -48,12 +49,19 @@ std::string PlatformUtils::documentsPath()
std::string retval;
std::wstring path(MAX_PATH,0);
- HRESULT result = SHGetFolderPathW(NULL, CSIDL_PERSONAL, NULL,
- SHGFP_TYPE_CURRENT, &path[0]);
+ HWND hwndOwner = 0;
+ int nFolder = CSIDL_PERSONAL;
+ HANDLE hToken = NULL;
+ DWORD dwFlags = SHGFP_TYPE_CURRENT;
+ LPTSTR pszPath = &path[0];
+
+ int result = SHGetFolderPathW( hwndOwner, nFolder, hToken, dwFlags, pszPath );
if (result == S_OK) {
path = std::wstring( path.c_str() ); // stip extra NULLs
+ //std::wcerr << "wchar path:" << "\n";
retval = winapi_wstr_to_utf8( path );
+ //PRINTB("Path found: %s",retval);
} else {
PRINT("ERROR: Could not find My Documents location");
retval = "";
diff --git a/src/PlatformUtils.cc b/src/PlatformUtils.cc
index 47569b0..5dd007d 100644
--- a/src/PlatformUtils.cc
+++ b/src/PlatformUtils.cc
@@ -7,7 +7,7 @@ bool PlatformUtils::createLibraryPath()
bool OK = false;
try {
if (!fs::exists(fs::path(path))) {
- PRINTB("Creating library folder %s", path );
+ //PRINTB("Creating library folder %s", path );
OK = fs::create_directories( path );
}
if (!OK) {
@@ -23,11 +23,14 @@ std::string PlatformUtils::libraryPath()
{
fs::path path;
try {
- path = boosty::canonical(fs::path(PlatformUtils::documentsPath()));
+ std::string pathstr = PlatformUtils::documentsPath();
+ if (pathstr=="") return "";
+ path = boosty::canonical(fs::path( pathstr ));
+ //PRINTB("path size %i",boosty::stringy(path).size());
+ //PRINTB("lib path found: [%s]", path );
if (path.empty()) return "";
path /= "OpenSCAD";
path /= "libraries";
- //PRINTB("path size %i",boosty::stringy(path).size());
//PRINTB("Appended path %s", path );
//PRINTB("Exists: %i", fs::exists(path) );
} catch (const fs::filesystem_error& ex) {
contact: Jan Huwald // Impressum