Change Linux userdata directory according to FreeDesktop standards:
https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html Patch from @x-qq
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include <cstdlib>
|
||||||
#include <boost/filesystem/operations.hpp>
|
#include <boost/filesystem/operations.hpp>
|
||||||
|
|
||||||
#include "res_image.hpp"
|
#include "res_image.hpp"
|
||||||
@@ -27,6 +28,8 @@ cursor_type Cursor::current = sword_curs;
|
|||||||
|
|
||||||
std::filebuf logfile;
|
std::filebuf logfile;
|
||||||
|
|
||||||
|
static fs::path get_posix_tempdir();
|
||||||
|
|
||||||
void init_directories(const char* exec_path) {
|
void init_directories(const char* exec_path) {
|
||||||
progDir = fs::canonical(exec_path);
|
progDir = fs::canonical(exec_path);
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
@@ -47,14 +50,12 @@ void init_directories(const char* exec_path) {
|
|||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
tempDir = getenv("APPDATA");
|
tempDir = getenv("APPDATA");
|
||||||
tempDir /= "Blades of Exile";
|
tempDir /= "Blades of Exile";
|
||||||
#else
|
#elif defined(__APPLE__)
|
||||||
tempDir = getenv("HOME");
|
tempDir = getenv("HOME");
|
||||||
#ifdef __APPLE__
|
|
||||||
tempDir /= "Library/Application Support/Blades of Exile";
|
tempDir /= "Library/Application Support/Blades of Exile";
|
||||||
#else
|
#else
|
||||||
tempDir /= ".oboe/blades";
|
tempDir = get_posix_tempdir();
|
||||||
#endif // __APPLE__
|
#endif
|
||||||
#endif // _Win32||_Win64
|
|
||||||
scenDir = tempDir/"Scenarios";
|
scenDir = tempDir/"Scenarios";
|
||||||
fs::create_directories(scenDir);
|
fs::create_directories(scenDir);
|
||||||
tempDir /= "Temporary Files";
|
tempDir /= "Temporary Files";
|
||||||
@@ -81,6 +82,30 @@ void init_directories(const char* exec_path) {
|
|||||||
std::cout << "Temporary directory: " << tempDir << std::endl;
|
std::cout << "Temporary directory: " << tempDir << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fs::path get_posix_tempdir() {
|
||||||
|
|
||||||
|
fs::path tempdir;
|
||||||
|
|
||||||
|
const char* xdg_config_dir = std::getenv("XDG_CONFIG_HOME");
|
||||||
|
|
||||||
|
if(xdg_config_dir != nullptr) {
|
||||||
|
tempdir = xdg_config_dir;
|
||||||
|
} else {
|
||||||
|
// Default to $HOME/.config
|
||||||
|
const char* home = std::getenv("HOME");
|
||||||
|
|
||||||
|
if(home == nullptr)
|
||||||
|
throw std::runtime_error { "HOME and XDG_CONFIG_HOME env variables not set!" };
|
||||||
|
|
||||||
|
tempdir = home;
|
||||||
|
tempdir /= ".config";
|
||||||
|
}
|
||||||
|
|
||||||
|
tempdir /= "openboe/blades";
|
||||||
|
|
||||||
|
return tempdir;
|
||||||
|
}
|
||||||
|
|
||||||
void check_for_intel() {
|
void check_for_intel() {
|
||||||
union {uint16_t x; uint8_t c;} endian;
|
union {uint16_t x; uint8_t c;} endian;
|
||||||
endian.x = 1;
|
endian.x = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user