mirror of
https://github.com/86Box/86Box.git
synced 2026-02-24 02:18:20 -07:00
Introduce a way to open a configuration file from the ROMs directory using rom_fopen and switch the FDD Audio configuration reader to it.
This commit is contained in:
@@ -34,6 +34,8 @@
|
||||
#define HAVE_STDARG_H
|
||||
#include <86box/86box.h>
|
||||
#include <86box/ini.h>
|
||||
#include <86box/mem.h>
|
||||
#include <86box/rom.h>
|
||||
#include <86box/plat.h>
|
||||
|
||||
typedef struct _list_ {
|
||||
@@ -360,9 +362,9 @@ ini_fgetws(wchar_t *str, int count, FILE *stream)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Read and parse the configuration file into memory. */
|
||||
/* Read and parse the configuration file into memory, with open type selection. */
|
||||
ini_t
|
||||
ini_read(const char *fn)
|
||||
ini_read_ex(const char *fn, int is_rom)
|
||||
{
|
||||
char sname[128];
|
||||
char ename[128];
|
||||
@@ -377,11 +379,20 @@ ini_read(const char *fn)
|
||||
list_t *head;
|
||||
|
||||
bom = ini_detect_bom(fn);
|
||||
|
||||
if (is_rom)
|
||||
#if defined(ANSI_CFG) || !defined(_WIN32)
|
||||
fp = plat_fopen(fn, "rt");
|
||||
fp = rom_fopen(fn, "rt");
|
||||
#else
|
||||
fp = plat_fopen(fn, "rt, ccs=UTF-8");
|
||||
fp = rom_fopen(fn, "rt, ccs=UTF-8");
|
||||
#endif
|
||||
else
|
||||
#if defined(ANSI_CFG) || !defined(_WIN32)
|
||||
fp = plat_fopen(fn, "rt");
|
||||
#else
|
||||
fp = plat_fopen(fn, "rt, ccs=UTF-8");
|
||||
#endif
|
||||
|
||||
if (fp == NULL)
|
||||
return NULL;
|
||||
|
||||
@@ -488,9 +499,16 @@ ini_read(const char *fn)
|
||||
return (ini_t) head;
|
||||
}
|
||||
|
||||
/* Write the in-memory configuration to disk. */
|
||||
/* Read and parse the configuration file into memory. */
|
||||
ini_t
|
||||
ini_read(const char *fn)
|
||||
{
|
||||
return ini_read_ex(fn, 0);
|
||||
}
|
||||
|
||||
/* Write the in-memory configuration to disk, with open type selection. */
|
||||
void
|
||||
ini_write(ini_t ini, const char *fn)
|
||||
ini_write_ex(ini_t ini, const char *fn, int is_rom)
|
||||
{
|
||||
wchar_t wtemp[512];
|
||||
list_t *list = (list_t *) ini;
|
||||
@@ -503,11 +521,19 @@ ini_write(ini_t ini, const char *fn)
|
||||
|
||||
sec = (section_t *) list->next;
|
||||
|
||||
if (is_rom)
|
||||
#if defined(ANSI_CFG) || !defined(_WIN32)
|
||||
fp = plat_fopen(fn, "wt");
|
||||
fp = rom_fopen(fn, "wt");
|
||||
#else
|
||||
fp = plat_fopen(fn, "wt, ccs=UTF-8");
|
||||
fp = rom_fopen(fn, "wt, ccs=UTF-8");
|
||||
#endif
|
||||
else
|
||||
#if defined(ANSI_CFG) || !defined(_WIN32)
|
||||
fp = plat_fopen(fn, "wt");
|
||||
#else
|
||||
fp = plat_fopen(fn, "wt, ccs=UTF-8");
|
||||
#endif
|
||||
|
||||
if (fp == NULL)
|
||||
return;
|
||||
|
||||
@@ -543,6 +569,13 @@ ini_write(ini_t ini, const char *fn)
|
||||
(void) fclose(fp);
|
||||
}
|
||||
|
||||
/* Write the in-memory configuration to disk. */
|
||||
void
|
||||
ini_write(ini_t ini, const char *fn)
|
||||
{
|
||||
ini_write_ex(ini, fn, 0);
|
||||
}
|
||||
|
||||
/* Wide-character version of "trim" */
|
||||
wchar_t *
|
||||
trim_w(wchar_t *str)
|
||||
|
||||
Reference in New Issue
Block a user