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 sToken;
|
||||||
std::string sSecret;
|
std::string sSecret;
|
||||||
std::string sVersionString;
|
std::string sVersionString;
|
||||||
std::string sHome;
|
std::string sConfigDirectory;
|
||||||
std::string sCookiePath;
|
std::string sCookiePath;
|
||||||
std::string sConfigFilePath;
|
std::string sConfigFilePath;
|
||||||
unsigned int iInstallerType;
|
unsigned int iInstallerType;
|
||||||
|
37
main.cpp
37
main.cpp
@ -33,12 +33,29 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
Config config;
|
Config config;
|
||||||
config.sVersionString = VERSION_STRING;
|
config.sVersionString = VERSION_STRING;
|
||||||
config.sHome = (std::string)getenv("HOME");
|
char *xdgconfig = getenv("XDG_CONFIG_HOME");
|
||||||
config.sCookiePath = config.sHome + "/.gogdownloader/cookies.txt";
|
char *xdgcache = getenv("XDG_CACHE_HOME");
|
||||||
config.sConfigFilePath = config.sHome + "/.gogdownloader/config.cfg";
|
std::string home = (std::string)getenv("HOME");
|
||||||
config.sXMLDirectory = config.sHome + "/.gogdownloader/xml";
|
|
||||||
|
|
||||||
// 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;
|
boost::filesystem::path path = config.sXMLDirectory;
|
||||||
if (!boost::filesystem::exists(path))
|
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
|
// Create help text for --platform option
|
||||||
std::string platform_text = "Select which installers are downloaded\n";
|
std::string platform_text = "Select which installers are downloaded\n";
|
||||||
unsigned int platform_sum = 0;
|
unsigned int platform_sum = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user