ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/BeOS/prefs_beos.cpp
Revision: 1.5
Committed: 2009-07-23T19:12:50Z (15 years, 3 months ago) by asvitkine
Branch: MAIN
CVS Tags: HEAD
Changes since 1.4: +1 -1 lines
Log Message:
support for .sheepvm bundles on macosx, containing "prefs" and "nvram" files

File Contents

# Content
1 /*
2 * prefs_beos.cpp - Preferences handling, BeOS specific things
3 *
4 * SheepShaver (C) 1997-2008 Christian Bauer and Marc Hellwig
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 #include <sys/stat.h>
26
27 #include "sysdeps.h"
28 #include "prefs.h"
29 #include "main.h"
30
31
32 // Platform-specific preferences items
33 prefs_desc platform_prefs_items[] = {
34 {"bitbang", TYPE_BOOLEAN, false, "draw Mac desktop directly on screen in window mode"},
35 {"idlewait", TYPE_BOOLEAN, false, "sleep when idle"},
36 {NULL, TYPE_END, false, NULL} // End of list
37 };
38
39
40 // Preferences file name and path
41 const char PREFS_FILE_NAME[] = "SheepShaver_prefs";
42 static BPath prefs_path;
43
44 // Modification date of prefs file
45 time_t PrefsFileDate = 0;
46
47
48 /*
49 * Load preferences from settings file
50 */
51
52 void LoadPrefs(const char *vmdir)
53 {
54 // Construct prefs path
55 find_directory(B_USER_SETTINGS_DIRECTORY, &prefs_path, true);
56 prefs_path.Append(PREFS_FILE_NAME);
57
58 // Read preferences from settings file
59 FILE *f = fopen(prefs_path.Path(), "r");
60 if (f == NULL) // Not found in settings directory, look in app directory
61 f = fopen(PREFS_FILE_NAME, "r");
62 if (f != NULL) {
63 LoadPrefsFromStream(f);
64
65 struct stat s;
66 fstat(fileno(f), &s);
67 PrefsFileDate = s.st_ctime;
68 fclose(f);
69
70 } else {
71
72 // No prefs file, save defaults
73 SavePrefs();
74 PrefsFileDate = real_time_clock();
75 }
76 }
77
78
79 /*
80 * Save preferences to settings file
81 */
82
83 void SavePrefs(void)
84 {
85 FILE *f;
86 if ((f = fopen(prefs_path.Path(), "w")) != NULL) {
87 SavePrefsToStream(f);
88 fclose(f);
89 }
90 }
91
92
93 /*
94 * Add defaults of platform-specific prefs items
95 * You may also override the defaults set in PrefsInit()
96 */
97
98 void AddPlatformPrefsDefaults(void)
99 {
100 PrefsReplaceString("extfs", "/boot");
101 PrefsAddInt32("windowmodes",
102 B_8_BIT_640x480 | B_15_BIT_640x480 | B_32_BIT_640x480 |
103 B_8_BIT_800x600 | B_15_BIT_800x600 | B_32_BIT_800x600
104 );
105 PrefsAddInt32("screenmodes",
106 B_8_BIT_640x480 | B_15_BIT_640x480 | B_32_BIT_640x480 |
107 B_8_BIT_800x600 | B_15_BIT_800x600 | B_32_BIT_800x600 |
108 B_8_BIT_1024x768 | B_15_BIT_1024x768
109 );
110 PrefsAddBool("bitbang", false);
111 PrefsAddBool("idlewait", true);
112 }