From cae29a1c1d8518fbeb1dd63c0b96a23fe99c7404 Mon Sep 17 00:00:00 2001 From: Sude Date: Mon, 17 Feb 2014 14:26:12 +0200 Subject: [PATCH] Add XDG Base Directory Specification support to Util::createXML I forgot to change Util::createXML in d430af6 --- src/util.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/util.cpp b/src/util.cpp index 523dad7..1bae463 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -81,9 +81,18 @@ int Util::createXML(std::string filepath, size_t chunk_size, std::string xml_dir FILE *xmlfile; size_t filesize, size; int chunks, i; - std::string home = (std::string)getenv("HOME"); + if (xml_dir.empty()) - xml_dir = home + "/.gogdownloader/xml"; + { + char *xdgcache = getenv("XDG_CACHE_HOME"); + if (xdgcache) + xml_dir = (std::string)xdgcache + "/lgogdownloader/xml"; + else + { + std::string home = (std::string)getenv("HOME"); + xml_dir = home + "/.cache/lgogdownloader/xml"; + } + } // Make sure directory exists boost::filesystem::path path = xml_dir;