From 55088c0183699a73d1fd3cb0cc3406ac93f5e243 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Thu, 2 Nov 2017 05:48:42 -0400 Subject: [PATCH] Use My Documents/Rack for local directory on Windows --- src/asset.cpp | 16 +++++++++++++--- src/main.cpp | 12 +++++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/asset.cpp b/src/asset.cpp index 8fc4d13c..f01e31c1 100644 --- a/src/asset.cpp +++ b/src/asset.cpp @@ -9,6 +9,11 @@ #include #endif +#if ARCH_WIN + #include + #include +#endif + namespace rack { @@ -76,9 +81,14 @@ std::string assetLocal(std::string filename) { path += "/" + filename; #endif #if ARCH_WIN - // TODO - // Use ~/My Documents/Rack or something - path = "./" + filename; + // Get My Documents folder + char buf[MAX_PATH]; + HRESULT result = SHGetFolderPath(NULL, CSIDL_MYDOCUMENTS, NULL, SHGFP_TYPE_CURRENT, buf); + assert(result == S_OK); + path = buf; + path += "/Rack"; + CreateDirectory(path.c_str(), NULL); + path += "/" + filename; #endif #if ARCH_LIN // TODO diff --git a/src/main.cpp b/src/main.cpp index 4fae38f7..3278c84a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -10,9 +10,15 @@ using namespace rack; int main(int argc, char* argv[]) { - char *cwd = getcwd(NULL, 0); - printf("Current working directory is %s\n", cwd); - free(cwd); + { + char *cwd = getcwd(NULL, 0); + printf("Current working directory: %s\n", cwd); + free(cwd); + std::string globalDir = assetGlobal(""); + std::string localDir = assetLocal(""); + printf("Global directory: %s\n", globalDir.c_str()); + printf("Local directory: %s\n", localDir.c_str()); + } pluginInit(); engineInit();