]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Copy config to configstore at startup.
authorToni Wilen <twilen@winuae.net>
Sat, 30 Jun 2018 10:12:10 +0000 (13:12 +0300)
committerToni Wilen <twilen@winuae.net>
Sat, 30 Jun 2018 10:12:10 +0000 (13:12 +0300)
cfgfile.cpp
include/options.h
include/zfile.h
main.cpp
zfile.cpp

index be04536d666fc49564b1b7c05d9658f977b564ca..91d95f12382eefdc3a81436538e028962b7089bb 100644 (file)
@@ -592,7 +592,7 @@ static TCHAR *getnextentry (const TCHAR **valuep, const TCHAR separator)
 static TCHAR *cfgfile_subst_path2 (const TCHAR *path, const TCHAR *subst, const TCHAR *file)
 {
        /* @@@ use strcasecmp for some targets.  */
-       if (_tcslen (path) > 0 && _tcsncmp (file, path, _tcslen (path)) == 0) {
+       if (path != NULL && subst != NULL && _tcslen (path) > 0 && _tcsncmp (file, path, _tcslen (path)) == 0) {
                int l;
                TCHAR *p2, *p = xmalloc (TCHAR, _tcslen (file) + _tcslen (subst) + 2);
                _tcscpy (p, subst);
@@ -675,6 +675,7 @@ static TCHAR *cfgfile_put_multipath (struct multipath *mp, const TCHAR *s)
        return my_strdup (s);
 }
 
+
 static TCHAR *cfgfile_subst_path_load (const TCHAR *path, struct multipath *mp, const TCHAR *file, bool dir)
 {
        TCHAR *s = cfgfile_get_multipath2 (mp, path, file, dir);
@@ -976,6 +977,39 @@ static void cfgfile_adjust_path(TCHAR *path, int maxsz, struct multipath *mp)
        xfree(s);
 }
 
+void cfgfile_resolve_path_out(const TCHAR *path, TCHAR *out, int size, int type)
+{
+       struct uae_prefs *p = &currprefs;
+       TCHAR *s = NULL;
+       switch (type)
+       {
+       case PATH_DIR:
+               s = cfgfile_subst_path_load(UNEXPANDED, &p->path_hardfile, path, true);
+               break;
+       case PATH_HDF:
+               s = cfgfile_subst_path_load(UNEXPANDED, &p->path_hardfile, path, true);
+               break;
+       case PATH_FLOPPY:
+               _tcscpy(out, path);
+               cfgfile_adjust_path(out, MAX_DPATH, &p->path_floppy);
+               break;
+       default:
+               s = cfgfile_subst_path(NULL, NULL, path);
+               break;
+       }
+       if (s) {
+               _tcscpy(out, s);
+               xfree(s);
+       }
+       my_resolvesoftlink(out, size);
+}
+
+void cfgfile_resolve_path(TCHAR *path, int size, int type)
+{
+       cfgfile_resolve_path_out(path, path, size, type);
+}
+
+
 static void write_filesys_config (struct uae_prefs *p, struct zfile *f)
 {
        TCHAR tmp[MAX_DPATH], tmp2[MAX_DPATH], tmp3[MAX_DPATH], hdcs[MAX_DPATH];
@@ -4702,8 +4736,10 @@ empty_fs:
                        memmove (uci.rootdir, uci.rootdir + 2, (_tcslen (uci.rootdir + 2) + 1) * sizeof (TCHAR));
                        uci.rootdir[0] = ':';
                }
+#if 0
                str = cfgfile_subst_path_load (UNEXPANDED, &p->path_hardfile, uci.rootdir, false);
                _tcscpy (uci.rootdir, str);
+#endif
        }
        if (uci.geometry[0]) {
                parse_geo(uci.geometry, &uci, NULL, false, true);
@@ -5279,6 +5315,8 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, const TCHAR *option, TCH
        if (cfgfile_yesno(option, value, _T("fpu_msvc_long_double"), &dummybool)) {
                if (dummybool)
                        p->fpu_mode = -1;
+               else if (p->fpu_mode < 0)
+                       p->fpu_mode = 0;
                return 1;
        }
 #endif
@@ -5816,7 +5854,6 @@ void cfgfile_compatibility_romtype(struct uae_prefs *p)
        romtype_restricted(p, restricted_pci);
 }
 
-static bool createconfigstore (struct uae_prefs*);
 static int getconfigstoreline (const TCHAR *option, TCHAR *value);
 
 static void calcformula (struct uae_prefs *prefs, TCHAR *in)
@@ -5830,7 +5867,7 @@ static void calcformula (struct uae_prefs *prefs, TCHAR *in)
        if (_tcslen (in) < 2 || in[0] != '[' || in[_tcslen (in) - 1] != ']')
                return;
        if (!configstore || updatestore)
-               createconfigstore (prefs);
+               cfgfile_createconfigstore (prefs);
        updatestore = false;
        if (!configstore)
                return;
@@ -6096,6 +6133,14 @@ static void subst (TCHAR *p, TCHAR *f, int n)
        free (str);
 }
 
+const TCHAR *cfgfile_getconfigdata(int *len)
+{
+       *len = -1;
+       if (!configstore)
+               return NULL;
+       return (TCHAR*)zfile_get_data_pointer(configstore, len);
+}
+
 static int getconfigstoreline (const TCHAR *option, TCHAR *value)
 {
        TCHAR tmp[CONFIG_BLEN * 2], tmp2[CONFIG_BLEN * 2];
@@ -6113,7 +6158,7 @@ static int getconfigstoreline (const TCHAR *option, TCHAR *value)
        }
 }
 
-static bool createconfigstore (struct uae_prefs *p)
+bool cfgfile_createconfigstore(struct uae_prefs *p)
 {
        uae_u8 zeros[4] = { 0 };
        zfile_fclose (configstore);
@@ -6981,7 +7026,7 @@ int cfgfile_searchconfig(const TCHAR *in, int index, TCHAR *out, int outsize)
        *out = 0;
 
        if (!configstore)
-               createconfigstore(&currprefs);
+               cfgfile_createconfigstore(&currprefs);
        if (!configstore)
                return 20;
 
@@ -7090,7 +7135,7 @@ uae_u32 cfgfile_modify (uae_u32 index, const TCHAR *parms, uae_u32 size, TCHAR *
        argv = cmdlineparser (parms, argc, UAELIB_MAX_PARSE);
 
        if (argv <= 1 && index == 0xffffffff) {
-               createconfigstore (&currprefs);
+               cfgfile_createconfigstore (&currprefs);
                xfree (configsearch);
                configsearch = NULL;
                if (!configstore) {
index 995112165896097a4bfe461381a4416a2274854e..b984f88f7f0f3bf1e9de62ba701e9c2c2f737e40 100644 (file)
@@ -938,6 +938,8 @@ extern void fixup_cpu (struct uae_prefs *prefs);
 extern void cfgfile_compatibility_romtype(struct uae_prefs *p);
 extern void cfgfile_compatibility_rtg(struct uae_prefs *p);
 extern bool cfgfile_detect_art(struct uae_prefs *p, TCHAR *path);
+extern const TCHAR *cfgfile_getconfigdata(int *len);
+extern bool cfgfile_createconfigstore(struct uae_prefs *p);
 
 extern void check_prefs_changed_custom (void);
 extern void check_prefs_changed_cpu (void);
index 878e5b772b94966a6a4666c4bcbe25573050c9e5..0d97583b6b2b9de3d126357e2be9b45c34f87910 100644 (file)
@@ -50,6 +50,7 @@ extern struct zfile *zfile_fopen_load_zfile (struct zfile *f);
 extern uae_u8 *zfile_load_data (const TCHAR *name, const uae_u8 *data,int datalen, int *outlen);
 extern uae_u8 *zfile_load_file(const TCHAR *name, int *outlen);
 extern struct zfile *zfile_fopen_parent (struct zfile*, const TCHAR*, uae_u64 offset, uae_u64 size);
+extern uae_u8 *zfile_get_data_pointer(struct zfile *z, int *len);
 
 extern int zfile_exists (const TCHAR *name);
 extern void zfile_fclose (struct zfile *);
index 93a6db379d2bf951060b38292c7f860520603265..abc7f51a559652bc1d2a0ec60a88558cb62f2b23 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -746,6 +746,7 @@ void fixup_prefs (struct uae_prefs *p, bool userconfig)
        blkdev_fix_prefs (p);
        inputdevice_fix_prefs(p, userconfig);
        target_fixup_options (p);
+       cfgfile_createconfigstore(p);
 }
 
 int quit_program = 0;
index 5fe73af023a963db46ada0c687aa33dc9e198fcb..a5636488273397b45515faf71e0a4fd7d1725d98 100644 (file)
--- a/zfile.cpp
+++ b/zfile.cpp
@@ -2092,6 +2092,15 @@ struct zfile *zfile_fopen_data (const TCHAR *name, uae_u64 size, const uae_u8 *d
        return l;
 }
 
+/* dump file use only */
+uae_u8 *zfile_get_data_pointer(struct zfile *z, int *len)
+{
+       if (!z->data)
+               return NULL;
+       *len = z->size;
+       return z->data;
+}
+
 uae_u8 *zfile_load_data (const TCHAR *name, const uae_u8 *data,int datalen, int *outlen)
 {
        struct zfile *zf, *f;