Browse Source

Use My Documents/Rack for local directory on Windows

tags/v0.5.0
Andrew Belt 7 years ago
parent
commit
55088c0183
2 changed files with 22 additions and 6 deletions
  1. +13
    -3
      src/asset.cpp
  2. +9
    -3
      src/main.cpp

+ 13
- 3
src/asset.cpp View File

@@ -9,6 +9,11 @@
#include <pwd.h>
#endif

#if ARCH_WIN
#include <Windows.h>
#include <Shlobj.h>
#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


+ 9
- 3
src/main.cpp View File

@@ -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();


Loading…
Cancel
Save