Skip to content

Commit

Permalink
store default of DownloadDir in springlobby.conf
Browse files Browse the repository at this point in the history
  • Loading branch information
abma committed Jul 31, 2014
1 parent c003ae1 commit 3c56a69
Showing 1 changed file with 22 additions and 24 deletions.
46 changes: 22 additions & 24 deletions src/utils/slpaths.cpp
Expand Up @@ -29,6 +29,27 @@

std::string SlPaths::m_user_defined_config_path = "";

// returns my documents dir on windows, HOME on windows
static std::string GetMyDocumentsDir()
{
#ifdef WIN32
wchar_t my_documents[MAX_PATH];
HRESULT result = SHGetFolderPathW(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, my_documents);
if (result == S_OK) return LSL::Util::ws2s(my_documents);
return "";
#else
const char* envvar= getenv("HOME");
if (envvar == NULL) return "";
return std::string(envvar);
#endif
}

#ifdef WIN32
SLCONFIG("/Spring/DownloadDir", LSL::Util::EnsureDelimiter(GetMyDocumentsDir()) + "My Games\\Spring", "Path where springlobby stores downloads");
#else
SLCONFIG("/Spring/DownloadDir", LSL::Util::EnsureDelimiter(GetMyDocumentsDir()) + ".spring", "Path where springlobby stores downloads");
#endif


std::string SlPaths::GetLocalConfigPath ()
{
Expand Down Expand Up @@ -77,23 +98,6 @@ std::map<std::string, LSL::SpringBundle> SlPaths::GetSpringVersionList()
return m_spring_versions;
}



// returns my documents dir on windows, HOME on windows
static std::string GetMyDocumentsDir()
{
#ifdef WIN32
wchar_t my_documents[MAX_PATH];
HRESULT result = SHGetFolderPathW(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, my_documents);
if (result == S_OK) return LSL::Util::ws2s(my_documents);
return "";
#else
const char* envvar= getenv("HOME");
if (envvar == NULL) return "";
return std::string(envvar);
#endif
}

//returns possible paths where a spring bundles could be
void SlPaths::PossibleEnginePaths(LSL::StringVector& pl)
{
Expand Down Expand Up @@ -431,13 +435,7 @@ std::string SlPaths::GetConfigfileDir()

std::string SlPaths::GetDownloadDir()
{
#ifdef WIN32
const std::string dir = LSL::Util::EnsureDelimiter(GetMyDocumentsDir()) + "My Games\\Spring";
#else
const std::string dir = LSL::Util::EnsureDelimiter(GetMyDocumentsDir()) + ".spring";
#endif
wxString downloadDir = TowxString(dir);
cfg().Read(_T("/Spring/DownloadDir"), &downloadDir);
const wxString downloadDir = cfg().ReadString(_T("/Spring/DownloadDir"));
return LSL::Util::EnsureDelimiter(STD_STRING(downloadDir));
}

Expand Down

0 comments on commit 3c56a69

Please sign in to comment.