Commit 4b2d3795 authored by Alexander Wiebel's avatar Alexander Wiebel

[ADD #403] on any architecture that has the environment variable HOME set we now read a

file called .walnut.cfg as default. If we do not find it or if HOME is not
defined we resort to the previous behavior.
parent 19eb6562
......@@ -24,6 +24,7 @@
#include <string>
#include <vector>
#include <cstdlib>
#include <boost/tokenizer.hpp>
......@@ -70,7 +71,22 @@ boost::filesystem::path WPathHelper::getAppPath()
boost::filesystem::path WPathHelper::getConfigFile()
{
// TODO(ebaum): we should prefer a user config file in ~.walnut.cfg in future. This needs to be platform independent of course.
return getPathHelper()->m_sharePath / "walnut.cfg";
namespace fs = boost::filesystem;
// I know that this work only for linux, but it should not break anything elsewhere.
// Thus, we prefer the file in the home directory now.
std::string homeDir = getenv( "HOME" ) ? getenv( "HOME" ) : "";
std::string linuxDefault= homeDir + "/.walnut.cfg";
boost::filesystem::path configFile;
if( fs::exists( linuxDefault ) )
{
configFile = boost::filesystem::path( linuxDefault );
}
else
{
configFile = getPathHelper()->m_sharePath / "walnut.cfg";
}
return configFile;
}
boost::filesystem::path WPathHelper::getFontPath()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment