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

Comparing SheepShaver/src/Unix/main_unix.cpp (file contents):
Revision 1.83 by asvitkine, 2009-02-11T20:44:49Z vs.
Revision 1.84 by asvitkine, 2009-07-23T19:12:50Z

# Line 89 | Line 89
89   #include <sys/mman.h>
90   #include <sys/ipc.h>
91   #include <sys/shm.h>
92 + #include <sys/stat.h>
93   #include <signal.h>
94  
95   #include "sysdeps.h"
# Line 360 | Line 361 | static void usage(const char *prg_name)
361          exit(0);
362   }
363  
364 + static bool valid_vmdir(const char *path)
365 + {
366 +        const int suffix_len = sizeof(".sheepvm") - 1;
367 +        int len = strlen(path);
368 +        if (len > suffix_len && !strcmp(path + len - suffix_len, ".sheepvm")) {
369 +                struct stat d;
370 +                if (!stat(path, &d) && S_ISDIR(d.st_mode)) {
371 +                        return true;
372 +                }
373 +        }
374 +        return false;
375 + }
376 +
377   int main(int argc, char **argv)
378   {
379          char str[256];
# Line 370 | Line 384 | int main(int argc, char **argv)
384          uint8 *rom_tmp;
385          time_t now, expire;
386          bool memory_mapped_from_zero;
387 +        const char *vmdir = NULL;
388  
389   #ifdef USE_SDL_VIDEO
390          // Don't let SDL block the screensaver
# Line 414 | Line 429 | int main(int argc, char **argv)
429                                  gui_connection_path = argv[i];
430                                  argv[i] = NULL;
431                          }
432 +                } else if (valid_vmdir(argv[i])) {
433 +                        vmdir = argv[i];
434 +                        argv[i] = NULL;
435 +                        printf("Using %s as vmdir.\n", vmdir);
436 +                        if (chdir(vmdir)) {
437 +                                printf("Failed to chdir to %s. Good bye.", vmdir);
438 +                                exit(1);
439 +                        }
440 +                        break;
441                  }
442          }
443  
# Line 448 | Line 472 | int main(int argc, char **argv)
472   #endif
473  
474          // Read preferences
475 <        PrefsInit(argc, argv);
475 >        PrefsInit(vmdir, argc, argv);
476  
477          // Any command line arguments left?
478          for (int i=1; i<argc; i++) {
# Line 895 | Line 919 | int main(int argc, char **argv)
919          delete[] rom_tmp;
920  
921          // Initialize everything
922 <        if (!InitAll())
922 >        if (!InitAll(vmdir))
923                  goto quit;
924          D(bug("Initialization complete\n"));
925  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines