1 |
/* |
2 |
* $Id: prefs_macosx.cpp,v 1.1 2002/03/16 04:00:26 nigel Exp $ |
3 |
* |
4 |
* prefs_macosx.cpp - Preferences handling, Unix specific. |
5 |
* Based on prefs_unix.cpp |
6 |
* |
7 |
* Basilisk II (C) 1997-2002 Christian Bauer |
8 |
* |
9 |
* This program is free software; you can redistribute it and/or modify |
10 |
* it under the terms of the GNU General Public License as published by |
11 |
* the Free Software Foundation; either version 2 of the License, or |
12 |
* (at your option) any later version. |
13 |
* |
14 |
* This program is distributed in the hope that it will be useful, |
15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 |
* GNU General Public License for more details. |
18 |
* |
19 |
* You should have received a copy of the GNU General Public License |
20 |
* along with this program; if not, write to the Free Software |
21 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
22 |
*/ |
23 |
|
24 |
#include "sysdeps.h" |
25 |
|
26 |
#include <stdio.h> |
27 |
#include <stdlib.h> |
28 |
|
29 |
#include "prefs.h" |
30 |
|
31 |
|
32 |
// Platform-specific preferences items |
33 |
prefs_desc platform_prefs_items[] = { |
34 |
{NULL, TYPE_END, false, NULL} // End of list |
35 |
}; |
36 |
|
37 |
|
38 |
// Prefs file name and path |
39 |
const char PREFS_FILE_NAME[] = ".basilisk_ii_prefs"; |
40 |
static char prefs_path[1024]; |
41 |
|
42 |
|
43 |
/* |
44 |
* Load preferences from settings file |
45 |
*/ |
46 |
|
47 |
void LoadPrefs(void) |
48 |
{ |
49 |
// Construct prefs path |
50 |
prefs_path[0] = 0; |
51 |
char *home = getenv("HOME"); |
52 |
if (home != NULL && strlen(home) < 1000) { |
53 |
strncpy(prefs_path, home, 1000); |
54 |
strcat(prefs_path, "/"); |
55 |
} |
56 |
strcat(prefs_path, PREFS_FILE_NAME); |
57 |
|
58 |
// Read preferences from settings file |
59 |
FILE *f = fopen(prefs_path, "r"); |
60 |
if (f != NULL) { |
61 |
|
62 |
// Prefs file found, load settings |
63 |
LoadPrefsFromStream(f); |
64 |
fclose(f); |
65 |
|
66 |
} else { |
67 |
|
68 |
// No prefs file, save defaults |
69 |
SavePrefs(); |
70 |
} |
71 |
} |
72 |
|
73 |
|
74 |
/* |
75 |
* Save preferences to settings file |
76 |
*/ |
77 |
|
78 |
void SavePrefs(void) |
79 |
{ |
80 |
FILE *f; |
81 |
if ((f = fopen(prefs_path, "w")) != NULL) { |
82 |
SavePrefsToStream(f); |
83 |
fclose(f); |
84 |
} |
85 |
} |
86 |
|
87 |
|
88 |
/* |
89 |
* Add defaults of platform-specific prefs items |
90 |
* You may also override the defaults set in PrefsInit() |
91 |
*/ |
92 |
|
93 |
void AddPlatformPrefsDefaults(void) |
94 |
{ |
95 |
PrefsReplaceString("extfs", "/"); |
96 |
PrefsReplaceString("screen", "win/512/384/16"); |
97 |
} |