hub, f1spirit: use config/settings

This commit is contained in:
Adrien Destugues
2015-11-13 10:06:49 +01:00
parent edb4d73fdb
commit 2440ba9f3d
2 changed files with 74 additions and 3 deletions

View File

@@ -1,4 +1,4 @@
From 1ddc81cdd051fabb1e56e861f5fd5a9da429029c Mon Sep 17 00:00:00 2001
From 9c38447f0d58b6ff39e7304ba9f63a82cbed5f92 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Tue, 21 Jan 2014 22:40:24 +0100
Subject: Remove outdated include.
@@ -17,5 +17,69 @@ index 59a213c..9cb48cc 100644
#include "F1Shttp.h"
--
1.8.3.4
2.2.2
From 235e4f4d2a1be22b66534f343eb03fa722d159bd Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Fri, 13 Nov 2015 09:33:23 +0100
Subject: Fix settings directory
diff --git a/sources/filehandling.cpp b/sources/filehandling.cpp
index 899df3a..353a3b7 100644
--- a/sources/filehandling.cpp
+++ b/sources/filehandling.cpp
@@ -1,5 +1,9 @@
#include "filehandling.h"
+#ifdef __HAIKU__
+#include <FindDirectory.h>
+#endif
+
#ifndef _WIN32
// make (sub)directories including multiple subdirs
int mkdirp(const char *fqfn, mode_t mode)
@@ -51,7 +55,11 @@ FILE *f1open(const char *f, const char *m, const enum filetype t)
case USERDATA:
// userdata is put in $HOME/.GAMENAME/
- snprintf(fname, STRLEN - 1, "%s/.%s/%s", getenv("HOME"), GAMENAME, f);
+ find_directory(B_USER_SETTINGS_DIRECTORY, 0, false, fname, STRLEN);
+ strcat(fname, "/");
+ strcat(fname, GAMENAME);
+ strcat(fname, "/");
+ strcat(fname, f);
// create subdirs if they don't exist
mkdirp(fname, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
// open file
diff --git a/sources/state_replaymanager.cpp b/sources/state_replaymanager.cpp
index 4aa1c99..b1a9f89 100644
--- a/sources/state_replaymanager.cpp
+++ b/sources/state_replaymanager.cpp
@@ -4,6 +4,10 @@
#include "dirent.h"
#endif
+#ifdef __HAIKU__
+#include <FindDirectory.h>
+#endif
+
#include "stdio.h"
#include "math.h"
#include "stdlib.h"
@@ -94,7 +98,10 @@ int F1SpiritApp::replaymanager_cycle(KEYBOARDSTATE *k)
char dir[STRLEN];
- snprintf(dir, STRLEN - 1, "%s/.%s/replays", getenv("HOME"), GAMENAME);
+ find_directory(B_USER_SETTINGS_DIRECTORY, 0, false, dir, STRLEN);
+ strcat(dir, "/");
+ strcat(dir, GAMENAME);
+ strcat(dir, "/replays");
dp = opendir(dir);
--
2.2.2