NVR files now stored per-config.

This commit is contained in:
SarahW 2017-10-11 21:36:41 +01:00
commit a44fcb196b
47 changed files with 32 additions and 4 deletions

View file

@ -5,6 +5,7 @@
#include "config.h"
char config_file_default[256];
char config_name[256];
static char config_file[256];

View file

@ -21,6 +21,7 @@ void config_dump(int is_global);
void config_free(int is_global);
extern char config_file_default[256];
extern char config_name[256];
#define CFG_MACHINE 0
#define CFG_GLOBAL 1

View file

@ -23,11 +23,32 @@ static int rtctime;
FILE *nvrfopen(char *fn, char *mode)
{
char s[512];
FILE *f;
strcpy(s, nvr_path);
put_backslash(s);
strcat(s, config_name);
strcat(s, ".");
strcat(s, fn);
return fopen(s, mode);
pclog("NVR try opening %s\n", s);
f = fopen(s, mode);
if (f)
return f;
if (mode[0] == 'r')
{
strcpy(s, nvr_path);
put_backslash(s);
strcat(s, "default");
put_backslash(s);
strcat(s, fn);
return fopen(s, mode);
}
else
{
pclog("Failed to open file '%s' for write\n", s);
return NULL;
}
}
void getnvrtime()

View file

@ -1,4 +1,5 @@
#include "ibm.h"
#include "nvr.h"
#include "vid_ati_eeprom.h"
enum
@ -33,7 +34,7 @@ void ati_eeprom_load(ati_eeprom_t *eeprom, char *fn, int type)
FILE *f;
eeprom->type = type;
strcpy(eeprom->fn, fn);
f = romfopen(eeprom->fn, "rb");
f = nvrfopen(eeprom->fn, "rb");
if (!f)
{
memset(eeprom->data, 0, eeprom->type ? 512 : 128);
@ -45,7 +46,7 @@ void ati_eeprom_load(ati_eeprom_t *eeprom, char *fn, int type)
void ati_eeprom_save(ati_eeprom_t *eeprom)
{
FILE *f = romfopen(eeprom->fn, "wb");
FILE *f = nvrfopen(eeprom->fn, "wb");
if (!f) return;
fwrite(eeprom->data, 1, eeprom->type ? 512 : 128, f);
fclose(f);

View file

@ -98,6 +98,9 @@ static int run(void* hdlg)
pclog("Config name %s\n", cfg);
strcpy(config_file_default, cfg);
strcpy(config_name, s);
if (config_name[strlen(config_name)-1] == '.')
config_name[strlen(config_name)-1] = 0;
wx_enddialog(hdlg, 1);
// pause = 0;