Haiku support (#596)
* Don't apply Wayland videodriver workaround on Haiku * dirent.d_type-less type detecting in IGFD The Dumb Way(tm). `stat`'s `st_mode` should be nicer? * CMake check for dirent.d_type, stat-based fallback * Move config dir setup to separate function Nicer to work with than macro kerfuffle. * Default sysFileDialog to off on Haiku * Logging stuff * Honour CMAKE_INSTALL_BINDIR * Use find_directory on Haiku Includes forgotten configPath line when home==NULL. * Address PR review notes
This commit is contained in:
parent
de77d51d7a
commit
e08399156a
8 changed files with 152 additions and 97 deletions
|
|
@ -23,11 +23,84 @@
|
|||
#include <fmt/printf.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "winStuff.h"
|
||||
#define CONFIG_FILE "\\furnace.cfg"
|
||||
#else
|
||||
#ifdef __HAIKU__
|
||||
#include <support/SupportDefs.h>
|
||||
#include <storage/FindDirectory.h>
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
#include <pwd.h>
|
||||
#include <sys/stat.h>
|
||||
#define CONFIG_FILE "/furnace.cfg"
|
||||
#endif
|
||||
|
||||
void DivEngine::initConfDir() {
|
||||
#ifdef _WIN32
|
||||
// maybe move this function in here instead?
|
||||
configPath=getWinConfigPath();
|
||||
#elif defined (IS_MOBILE)
|
||||
configPath=SDL_GetPrefPath();
|
||||
#else
|
||||
#ifdef __HAIKU__
|
||||
char userSettingsDir[PATH_MAX];
|
||||
status_t findUserDir = find_directory(B_USER_SETTINGS_DIRECTORY,0,true,userSettingsDir,PATH_MAX);
|
||||
if (findUserDir==B_OK) {
|
||||
configPath=userSettingsDir;
|
||||
} else {
|
||||
logW("unable to find/create user settings directory (%s)!",strerror(findUserDir));
|
||||
configPath=".";
|
||||
return;
|
||||
}
|
||||
#else
|
||||
// TODO this should check XDG_CONFIG_HOME first
|
||||
char* home=getenv("HOME");
|
||||
if (home==NULL) {
|
||||
int uid=getuid();
|
||||
struct passwd* entry=getpwuid(uid);
|
||||
if (entry==NULL) {
|
||||
logW("unable to determine home directory (%s)!",strerror(errno));
|
||||
configPath=".";
|
||||
return;
|
||||
} else {
|
||||
configPath=entry->pw_dir;
|
||||
}
|
||||
} else {
|
||||
configPath=home;
|
||||
}
|
||||
#ifdef __APPLE__
|
||||
configPath+="/Library/Application Support";
|
||||
#else
|
||||
// FIXME this doesn't honour XDG_CONFIG_HOME *at all*
|
||||
configPath+="/.config";
|
||||
#endif // __APPLE__
|
||||
#endif // __HAIKU__
|
||||
#ifdef __APPLE__
|
||||
configPath+="/Furnace";
|
||||
#else
|
||||
configPath+="/furnace";
|
||||
#endif // __APPLE__
|
||||
struct stat st;
|
||||
std::string pathSep="/";
|
||||
configPath+=pathSep;
|
||||
size_t sepPos=configPath.find(pathSep,1);
|
||||
while (sepPos!=std::string::npos) {
|
||||
std::string subpath=configPath.substr(0,sepPos++);
|
||||
if (stat(subpath.c_str(),&st)!=0) {
|
||||
logI("creating config path element %s ...",subpath.c_str());
|
||||
if (mkdir(subpath.c_str(),0755)!=0) {
|
||||
logW("could not create config path element %s! (%s)",subpath.c_str(),strerror(errno));
|
||||
configPath=".";
|
||||
return;
|
||||
}
|
||||
}
|
||||
sepPos=configPath.find(pathSep,sepPos);
|
||||
}
|
||||
configPath.resize(configPath.length()-pathSep.length());
|
||||
#endif // _WIN32
|
||||
}
|
||||
|
||||
bool DivEngine::saveConf() {
|
||||
configFile=configPath+String(CONFIG_FILE);
|
||||
FILE* f=ps_fopen(configFile.c_str(),"wb");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue