From 93d31e03749d11a8b656e074300ec46fe16dabb7 Mon Sep 17 00:00:00 2001 From: omigamedev Date: Mon, 17 Sep 2018 22:39:32 +0200 Subject: [PATCH] search and use user's Documents folder on Windows --- src/app.cpp | 22 +++++++++++++++++++--- src/main.cpp | 4 ---- src/pch.cpp | 4 ++++ src/pch.h | 1 + 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/app.cpp b/src/app.cpp index 1310fc7..3e47552 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -114,10 +114,26 @@ void App::initLog() //sprintf_s(path, "%s%s", out_drive, out_path); //data_path = path; - CHAR path[MAX_PATH]; - GetCurrentDirectoryA(sizeof(path), path); - data_path = path; + + CHAR my_documents[MAX_PATH]; + HRESULT result = SHGetFolderPathA(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, my_documents); + if (SUCCEEDED(result)) + { + std::string path = std::string(my_documents) + "\\PanoPainter"; + if (!PathFileExistsA(path.c_str())) + CreateDirectoryA(path.c_str(), NULL); + App::I.data_path = path; + } + else + { + CHAR path[MAX_PATH]; + GetCurrentDirectoryA(sizeof(path), path); + data_path = path; + } + rec_path = data_path + "\\frames"; + if (!PathFileExistsA(rec_path.c_str())) + CreateDirectoryA(rec_path.c_str(), NULL); #endif //LogRemote::I.start(); diff --git a/src/main.cpp b/src/main.cpp index 2301410..bd4fcdc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -13,10 +13,6 @@ #include #include -#pragma comment (lib, "opengl32.lib") -#pragma comment (lib, "glew32.lib") -#pragma comment(lib, "wbemuuid.lib") - #define WM_USER_CLOSE (WM_USER + 1) LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp); diff --git a/src/pch.cpp b/src/pch.cpp index f9002de..c32b633 100644 --- a/src/pch.cpp +++ b/src/pch.cpp @@ -16,4 +16,8 @@ #ifdef _WIN32 #pragma comment(lib, "BugTrapU-x64.lib") #pragma comment(lib, "shell32.lib") + #pragma comment(lib, "opengl32.lib") + #pragma comment(lib, "glew32.lib") + #pragma comment(lib, "wbemuuid.lib") + #pragma comment(lib, "Shlwapi.lib") #endif // _WIN32 diff --git a/src/pch.h b/src/pch.h index b21f7de..321fcec 100644 --- a/src/pch.h +++ b/src/pch.h @@ -77,6 +77,7 @@ #include #include #include + #include #define SHADER_VERSION "#version 150\n"