Added musik::core::GetHomeDirectory(), wired it into DirectoryAdapter

This commit is contained in:
Casey Langen 2016-06-23 01:13:54 -07:00
parent 59a2a4794f
commit 4cc9e33c55
3 changed files with 16 additions and 3 deletions

View File

@ -88,7 +88,7 @@ std::string musik::core::GetApplicationDirectory() {
return result;
}
std::string musik::core::GetDataDirectory() {
std::string musik::core::GetHomeDirectory() {
std::string directory;
#ifdef WIN32
@ -96,10 +96,20 @@ std::string musik::core::GetDataDirectory() {
wchar_t *buffer = new wchar_t[bufferSize + 2];
GetEnvironmentVariable(_T("APPDATA"), buffer, bufferSize);
directory.assign(u16to8(buffer));
directory.append("/mC2/");
delete[] buffer;
#else
directory = std::string(std::getenv("HOME"));
#endif
return directory;
}
std::string musik::core::GetDataDirectory() {
std::string directory = GetHomeDirectory();
#ifdef WIN32
directory.append("/mC2/");
#else
directory.append("/.mC2/");
#endif

View File

@ -39,6 +39,7 @@
namespace musik { namespace core {
std::string GetHomeDirectory();
std::string GetApplicationDirectory();
std::string GetDataDirectory();
std::string GetPath(const std::string &sFile);

View File

@ -34,6 +34,8 @@
#include "stdafx.h"
#include <core/support/Common.h>
#include <cursespp/ScrollAdapterBase.h>
#include <cursespp/SingleLineEntry.h>
@ -67,7 +69,7 @@ void buildDirectoryList(const path& p, std::vector<std::string>& target)
}
DirectoryAdapter::DirectoryAdapter() {
this->dir = "/Users/clangen";
this->dir = musik::core::GetHomeDirectory();
buildDirectoryList(this->dir, this->subdirs);
}