mirror of
https://github.com/clangen/musikcube.git
synced 2024-11-19 11:10:52 +00:00
Fixed a few bugs when resolving home and data directories.
This commit is contained in:
parent
f939db9592
commit
1501d883ee
@ -149,6 +149,22 @@ namespace musik { namespace core {
|
||||
std::string GetHomeDirectory() {
|
||||
std::string directory;
|
||||
|
||||
#ifdef WIN32
|
||||
DWORD bufferSize = GetEnvironmentVariable(L"HOMEPATH", 0, 0);
|
||||
wchar_t* buffer = new wchar_t[bufferSize + 2];
|
||||
GetEnvironmentVariable(L"HOMEPATH", buffer, bufferSize);
|
||||
directory.assign(u16to8(buffer));
|
||||
delete[] buffer;
|
||||
#else
|
||||
directory = std::string(std::getenv("HOME"));
|
||||
#endif
|
||||
|
||||
return directory;
|
||||
}
|
||||
|
||||
std::string GetDataDirectory(bool create) {
|
||||
std::string directory;
|
||||
|
||||
#ifdef WIN32
|
||||
DWORD bufferSize = GetEnvironmentVariable(L"APPDATA", 0, 0);
|
||||
wchar_t* buffer = new wchar_t[bufferSize + 2];
|
||||
@ -165,11 +181,7 @@ namespace musik { namespace core {
|
||||
}
|
||||
#endif
|
||||
|
||||
return directory;
|
||||
}
|
||||
|
||||
std::string GetDataDirectory(bool create) {
|
||||
std::string directory = GetHomeDirectory() + std::string("/musikcube/");
|
||||
directory += std::string("/musikcube/");
|
||||
|
||||
if (create) {
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user