Add ability to save/read files based on XDG specification

Fix some \\ in paths to be /
This commit is contained in:
Andrew Udvare 2022-08-30 11:48:47 -04:00
parent 15b71c57dd
commit 730a3791a1
No known key found for this signature in database
GPG key ID: 1AFD9AFC120C26DD
30 changed files with 254 additions and 135 deletions

View file

@ -67,7 +67,7 @@ bool DownloadGraphicPacksWindow::curlDownloadFile(const char *url, curlDownloadF
bool checkGraphicPackDownloadedVersion(const char* nameVersion, bool& hasVersionFile)
{
hasVersionFile = false;
const auto path = ActiveSettings::GetPath("graphicPacks/downloadedGraphicPacks/version.txt");
const auto path = ActiveSettings::GetDataPath("graphicPacks/downloadedGraphicPacks/version.txt");
std::unique_ptr<FileStream> file(FileStream::openFile2(path));
std::string versionInFile;
@ -80,7 +80,7 @@ bool checkGraphicPackDownloadedVersion(const char* nameVersion, bool& hasVersion
void createGraphicPackDownloadedVersionFile(const char* nameVersion)
{
const auto path = ActiveSettings::GetPath("graphicPacks/downloadedGraphicPacks/version.txt");
const auto path = ActiveSettings::GetDataPath("graphicPacks/downloadedGraphicPacks/version.txt");
std::unique_ptr<FileStream> file(FileStream::createFile2(path));
if (file)
file->writeString(nameVersion);
@ -92,7 +92,7 @@ void createGraphicPackDownloadedVersionFile(const char* nameVersion)
void deleteDownloadedGraphicPacks()
{
const auto path = ActiveSettings::GetPath("graphicPacks/downloadedGraphicPacks");
const auto path = ActiveSettings::GetDataPath("graphicPacks/downloadedGraphicPacks");
std::error_code er;
if (!fs::exists(path))
return;
@ -240,7 +240,7 @@ void DownloadGraphicPacksWindow::UpdateThread()
return;
}
auto path = ActiveSettings::GetPath("graphicPacks/downloadedGraphicPacks");
auto path = ActiveSettings::GetDataPath("graphicPacks/downloadedGraphicPacks");
std::error_code er;
//fs::remove_all(path, er); -> Don't delete the whole folder and recreate it immediately afterwards because sometimes it just fails
deleteDownloadedGraphicPacks();
@ -260,7 +260,7 @@ void DownloadGraphicPacksWindow::UpdateThread()
std::strstr(sb.name, "..\\") != nullptr)
continue; // bad path
path = ActiveSettings::GetPath("graphicPacks/downloadedGraphicPacks/{}", sb.name);
path = ActiveSettings::GetDataPath("graphicPacks/downloadedGraphicPacks/{}", sb.name);
size_t sbNameLen = strlen(sb.name);
if(sbNameLen == 0)