ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/BeOS/prefs_beos.cpp
Revision: 1.9
Committed: 2008-01-01T09:40:32Z (16 years, 4 months ago) by gbeauche
Branch: MAIN
CVS Tags: HEAD
Changes since 1.8: +1 -1 lines
Log Message:
Happy New Year!

File Contents

# Content
1 /*
2 * prefs_beos.cpp - Preferences handling, BeOS specific stuff
3 *
4 * Basilisk II (C) 1997-2008 Christian Bauer
5 *
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 {"powerrom", TYPE_STRING, false, "path of PowerMac ROM"},
34 {NULL, TYPE_END, false, NULL} // End of list
35 };
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 PrefsReplaceString("extfs", "/boot");
91 }