Merge pull request #4 from Crestwave/haiku

Add support for Haiku's config directory
This commit is contained in:
Layla Marchant 2020-02-26 22:21:39 -05:00 committed by GitHub
commit c68dd0b447
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 0 deletions

View File

@ -22,9 +22,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <sys/stat.h>
#include <unistd.h>
#ifdef __HAIKU__
#include <FindDirectory.h>
#else
#ifndef _WIN32
#include <pwd.h>
#endif
#endif
#include "SDL.h"
@ -211,6 +215,17 @@ void engine_setupConfigDirectory()
if ((mkdir(dir) != 0) && (errno != EEXIST))
engine_showError(2, dir);
snprintf(engine.configDirectory, PATH_MAX, "%s/", dir);
#elif __HAIKU__
subdir = "starfighter";
char path[PATH_MAX];
if (find_directory(B_USER_SETTINGS_DIRECTORY, 0, false, path, PATH_MAX) == B_OK)
snprintf(dir, PATH_MAX, "%s/%s", path, subdir);
if ((mkdir(dir, S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH) != 0) && (errno != EEXIST))
engine_showError(2, dir);
snprintf(engine.configDirectory, PATH_MAX, "%s/", dir);
#else
subdir = "starfighter";