defendguin: loads from and saves in Haiku's settings directory (#4584)

This commit is contained in:
Raheem Idowu
2020-01-15 15:44:42 +04:00
committed by Jérôme Duval
parent fa384271c2
commit a4ba73099a
2 changed files with 63 additions and 1 deletions

View File

@@ -5,9 +5,10 @@ from being captured and mutated."
HOMEPAGE="http://www.newbreedsoftware.com/defendguin/"
COPYRIGHT="1999-2009 Bill Kendrick"
LICENSE="GNU GPL v2"
REVISION="3"
REVISION="4"
SOURCE_URI="ftp://ftp.tuxpaint.org/unix/x/defendguin/src/defendguin-0.0.12.tar.gz"
CHECKSUM_SHA256="3c248bed480b291901b7509525dc952be6d28dfa47fd6f8e3fb9873f46017330"
PATCHES="defendguin-$portVersion.patchset"
ARCHITECTURES="x86_gcc2 x86 x86_64"

View File

@@ -0,0 +1,61 @@
From 64c29df0298e2bd1c036047f47cb2dbc36f70972 Mon Sep 17 00:00:00 2001
From: Abdur-Raheem Idowu <abdurraheemidowu@gmail.com>
Date: Wed, 15 Jan 2020 09:57:38 +0000
Subject: Loads&saves in Haiku's settings directory
diff --git a/src/defendguin.c b/src/defendguin.c
index 60f04e8..d4f1a18 100644
--- a/src/defendguin.c
+++ b/src/defendguin.c
@@ -33,6 +33,9 @@
#define M_PI 3.14159265358979323846 /* mmm... pi... */
#endif /* #ifndef M_PI */
+#ifdef __HAIKU__
+#include <FindDirectory.h>
+#endif
/* Image enumerations: */
@@ -5884,7 +5887,18 @@ void load_options(void)
if (getenv("HOME") != NULL)
{
+#ifdef __HAIKU__
+ char path[PATH_MAX];
+ dev_t bootdev = dev_for_path("/boot");
+ if (bootdev < 0)
+ bootdev = 0;
+ if (find_directory(B_USER_SETTINGS_DIRECTORY, bootdev, false,
+ path, sizeof(path) - 1) == B_OK) {
+ snprintf(fname, sizeof(fname), "%s/defendguinrc", path);
+ }
+#else
snprintf(fname, sizeof(fname), "%s/.defendguinrc", getenv("HOME"));
+#endif
fi = fopen(fname, "r");
@@ -5948,7 +5962,18 @@ void save_options(void)
if (getenv("HOME") != NULL)
{
+#ifdef __HAIKU__
+ char path[PATH_MAX];
+ dev_t bootdev = dev_for_path("/boot");
+ if (bootdev < 0)
+ bootdev = 0;
+ if (find_directory(B_USER_SETTINGS_DIRECTORY, bootdev, false,
+ path, sizeof(path) - 1) == B_OK) {
+ snprintf(fname, sizeof(fname), "%s/defendguinrc", path);
+ }
+#else
snprintf(fname, sizeof(fname), "%s/.defendguinrc", getenv("HOME"));
+#endif
fi = fopen(fname, "w");
--
2.19.0