Skip to content

Commit

Permalink
linux: Restore datapath and userDataPath calculations
Browse files Browse the repository at this point in the history
In a95e810, removed datapath and userDataPath calculations by
mistake. This commit restores them. In addition, check on macOS and
Linux that the environment HOME, because at least artificially you
can create an environment where it doesn't.

Fixes: #487 ("Linux Paths")
  • Loading branch information
jarkkojs committed Feb 4, 2019
1 parent ee25e8f commit c548845
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/common/SurgeStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,13 @@ SurgeStorage::SurgeStorage()

memset(&audio_in[0][0], 0, 2 * BLOCK_SIZE_OS * sizeof(float));

#if MAC || LINUX
const char* homePath = getenv("HOME");
if (!homePath)
throw Surge::Error("The environment variable HOME does not exist",
"Surge failed to initialize");
#endif

#if MAC
char path[1024];
FSRef foundRef;
Expand All @@ -161,8 +168,16 @@ SurgeStorage::SurgeStorage()
}

// ~/Documents/Surge in full name
sprintf( path, "%s/Documents/Surge", getenv( "HOME" ) );
sprintf(path, "%s/Documents/Surge", homePath);
userDataPath = path;
#elif LINUX
const char* xdgDataPath = getenv("XDG_DATA_HOME");
if (xdgDataPath)
datapath = std::string(xdgDataPath) + "/Surge/";
else
datapath = std::string(homePath) + "/.local/share/Surge/";

userDataPath = std::string(homePath) + "/Documents/Surge";
#elif WINDOWS
PWSTR localAppData;
if (!SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, nullptr, &localAppData))
Expand Down

0 comments on commit c548845

Please sign in to comment.