1 |
|
/* |
2 |
|
* xpram_unix.cpp - XPRAM handling, Unix specific stuff |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-2000 Christian Bauer |
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 |
26 |
|
|
27 |
|
|
28 |
|
// XPRAM file name and path |
29 |
+ |
#if POWERPC_ROM |
30 |
+ |
const char XPRAM_FILE_NAME[] = ".sheepshaver_nvram"; |
31 |
+ |
#else |
32 |
|
const char XPRAM_FILE_NAME[] = ".basilisk_ii_xpram"; |
33 |
+ |
#endif |
34 |
|
static char xpram_path[1024]; |
35 |
|
|
36 |
|
|
38 |
|
* Load XPRAM from settings file |
39 |
|
*/ |
40 |
|
|
41 |
< |
void LoadXPRAM(void) |
41 |
> |
void LoadXPRAM(const char *vmdir) |
42 |
|
{ |
43 |
< |
// Construct XPRAM path |
44 |
< |
xpram_path[0] = 0; |
45 |
< |
char *home = getenv("HOME"); |
46 |
< |
if (home != NULL && strlen(home) < 1000) { |
47 |
< |
strncpy(xpram_path, home, 1000); |
48 |
< |
strcat(xpram_path, "/"); |
43 |
> |
if (vmdir) { |
44 |
> |
#if POWERPC_ROM |
45 |
> |
snprintf(xpram_path, sizeof(xpram_path), "%s/nvram", vmdir); |
46 |
> |
#else |
47 |
> |
snprintf(xpram_path, sizeof(xpram_path), "%s/xpram", vmdir); |
48 |
> |
#endif |
49 |
> |
} else { |
50 |
> |
// Construct XPRAM path |
51 |
> |
xpram_path[0] = 0; |
52 |
> |
char *home = getenv("HOME"); |
53 |
> |
if (home != NULL && strlen(home) < 1000) { |
54 |
> |
strncpy(xpram_path, home, 1000); |
55 |
> |
strcat(xpram_path, "/"); |
56 |
> |
} |
57 |
> |
strcat(xpram_path, XPRAM_FILE_NAME); |
58 |
|
} |
46 |
– |
strcat(xpram_path, XPRAM_FILE_NAME); |
59 |
|
|
60 |
|
// Load XPRAM from settings file |
61 |
|
int fd; |
62 |
|
if ((fd = open(xpram_path, O_RDONLY)) >= 0) { |
63 |
< |
read(fd, XPRAM, 256); |
63 |
> |
read(fd, XPRAM, XPRAM_SIZE); |
64 |
|
close(fd); |
65 |
|
} |
66 |
|
} |
74 |
|
{ |
75 |
|
int fd; |
76 |
|
if ((fd = open(xpram_path, O_WRONLY | O_CREAT, 0666)) >= 0) { |
77 |
< |
write(fd, XPRAM, 256); |
77 |
> |
write(fd, XPRAM, XPRAM_SIZE); |
78 |
|
close(fd); |
79 |
|
} |
80 |
|
} |