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