mirror of
https://github.com/Sude-/lgogdownloader.git
synced 2024-11-20 11:49:17 +01:00
Support XDG Base Directory Specification
Configuration files and cookies are now stored in "$XDG_CONFIG_HOME/lgogdownloader" if $XDG_CONFIG_HOME is not set it will use "$HOME/.config/lgogdownloader" XML files are now stored in "$XDG_CACHE_HOME/lgogdownloader/xml" if $XDG_CACHE_HOME is not set it will use "$HOME/.cache/lgogdownloader/xml"
This commit is contained in:
parent
65f407d076
commit
d430af63d0
@ -41,7 +41,7 @@ class Config
|
||||
std::string sToken;
|
||||
std::string sSecret;
|
||||
std::string sVersionString;
|
||||
std::string sHome;
|
||||
std::string sConfigDirectory;
|
||||
std::string sCookiePath;
|
||||
std::string sConfigFilePath;
|
||||
unsigned int iInstallerType;
|
||||
|
37
main.cpp
37
main.cpp
@ -33,12 +33,29 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
Config config;
|
||||
config.sVersionString = VERSION_STRING;
|
||||
config.sHome = (std::string)getenv("HOME");
|
||||
config.sCookiePath = config.sHome + "/.gogdownloader/cookies.txt";
|
||||
config.sConfigFilePath = config.sHome + "/.gogdownloader/config.cfg";
|
||||
config.sXMLDirectory = config.sHome + "/.gogdownloader/xml";
|
||||
char *xdgconfig = getenv("XDG_CONFIG_HOME");
|
||||
char *xdgcache = getenv("XDG_CACHE_HOME");
|
||||
std::string home = (std::string)getenv("HOME");
|
||||
|
||||
// Create gogdownloader directories
|
||||
if (xdgconfig)
|
||||
{
|
||||
config.sConfigDirectory = (std::string)xdgconfig + "/lgogdownloader";
|
||||
config.sCookiePath = config.sConfigDirectory + "/cookies.txt";
|
||||
config.sConfigFilePath = config.sConfigDirectory + "/config.cfg";
|
||||
}
|
||||
else
|
||||
{
|
||||
config.sConfigDirectory = home + "/.config/lgogdownloader";
|
||||
config.sCookiePath = config.sConfigDirectory + "/cookies.txt";
|
||||
config.sConfigFilePath = config.sConfigDirectory + "/config.cfg";
|
||||
}
|
||||
|
||||
if (xdgcache)
|
||||
config.sXMLDirectory = (std::string)xdgcache + "/lgogdownloader/xml";
|
||||
else
|
||||
config.sXMLDirectory = home + "/.cache/lgogdownloader/xml";
|
||||
|
||||
// Create lgogdownloader directories
|
||||
boost::filesystem::path path = config.sXMLDirectory;
|
||||
if (!boost::filesystem::exists(path))
|
||||
{
|
||||
@ -49,6 +66,16 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
path = config.sConfigDirectory;
|
||||
if (!boost::filesystem::exists(path))
|
||||
{
|
||||
if (!boost::filesystem::create_directories(path))
|
||||
{
|
||||
std::cout << "Failed to create directory: " << path << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Create help text for --platform option
|
||||
std::string platform_text = "Select which installers are downloaded\n";
|
||||
unsigned int platform_sum = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user