ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/xpram_unix.cpp
(Generate patch)

Comparing BasiliskII/src/Unix/xpram_unix.cpp (file contents):
Revision 1.1.1.1 by cebix, 1999-10-03T14:16:25Z vs.
Revision 1.10 by asvitkine, 2009-07-23T19:19:14Z

# Line 1 | Line 1
1   /*
2   *  xpram_unix.cpp - XPRAM handling, Unix specific stuff
3   *
4 < *  Basilisk II (C) 1997-1999 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
# Line 26 | Line 26
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  
# Line 34 | Line 38 | static char xpram_path[1024];
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   }
# Line 61 | Line 73 | void LoadXPRAM(void)
73   void SaveXPRAM(void)
74   {
75          int fd;
76 <        if ((fd = open(xpram_path, O_WRONLY | O_CREAT, 0644)) >= 0) {
77 <                write(fd, XPRAM, 256);
76 >        if ((fd = open(xpram_path, O_WRONLY | O_CREAT, 0666)) >= 0) {
77 >                write(fd, XPRAM, XPRAM_SIZE);
78                  close(fd);
79          }
80   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines