From e611573153f7ddd2cc19a8f7e5fb86929ee6bfb6 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sat, 3 Feb 2024 15:57:35 +0200 Subject: [PATCH] Quickstart disk image/executable drag&drop check, insert in harddrives if archive with multiple executables. --- include/zfile.h | 1 + main.cpp | 3 ++- od-win32/win32.cpp | 1 + od-win32/win32gui.cpp | 14 ++++++++++---- zfile.cpp | 2 +- zfile_archive.cpp | 22 ++++++++++++++++++++-- 6 files changed, 35 insertions(+), 8 deletions(-) diff --git a/include/zfile.h b/include/zfile.h index 92fabf8f..b7f09691 100644 --- a/include/zfile.h +++ b/include/zfile.h @@ -119,6 +119,7 @@ extern int zfile_truncate(struct zfile *z, uae_s64 size); #define ZFILE_NVR 7 #define ZFILE_HDFRDB 8 #define ZFILE_CDIMAGE 9 +#define ZFILE_EXECUTABLE 10 extern const TCHAR *uae_archive_extensions[]; extern const TCHAR *uae_ignoreextensions[]; diff --git a/main.cpp b/main.cpp index 79418a5e..86f29743 100644 --- a/main.cpp +++ b/main.cpp @@ -885,7 +885,8 @@ static int diskswapper_cb (struct zfile *f, void *vrsd) int *num = (int*)vrsd; if (*num >= MAX_SPARE_DRIVES) return 1; - if (zfile_gettype (f) == ZFILE_DISKIMAGE) { + int type = zfile_gettype(f); + if (type == ZFILE_DISKIMAGE || type == ZFILE_EXECUTABLE) { _tcsncpy (currprefs.dfxlist[*num], zfile_getname (f), 255); (*num)++; } diff --git a/od-win32/win32.cpp b/od-win32/win32.cpp index d5caf058..57de75e9 100644 --- a/od-win32/win32.cpp +++ b/od-win32/win32.cpp @@ -7220,6 +7220,7 @@ static int process_arg (TCHAR *cmdline, TCHAR **xargv, TCHAR ***xargv3) _stprintf (tmp, _T("-cdimage=%s"), f); break; case ZFILE_DISKIMAGE: + case ZFILE_EXECUTABLE: if (fd < 4) _stprintf (tmp, _T("-cfgparam=floppy%d=%s"), fd++, f); break; diff --git a/od-win32/win32gui.cpp b/od-win32/win32gui.cpp index 1569a7be..5ecdb7ff 100644 --- a/od-win32/win32gui.cpp +++ b/od-win32/win32gui.cpp @@ -17325,8 +17325,9 @@ static void diskswapper_addfile (struct uae_prefs *prefs, const TCHAR *file) struct zfile *zf = zfile_fopen (out, _T("rb"), ZFD_NORMAL); if (zf) { int type = zfile_gettype (zf); - if (type == ZFILE_DISKIMAGE) + if (type == ZFILE_DISKIMAGE || type == ZFILE_EXECUTABLE) { diskswapper_addfile2 (prefs, out); + } zfile_fclose (zf); } } @@ -22377,7 +22378,7 @@ static int floppyslot_addfile (struct uae_prefs *prefs, const TCHAR *filepath, c struct zfile *zf = zfile_fopen (out, _T("rb"), ZFD_NORMAL); if (zf) { int type = zfile_gettype (zf); - if (type == ZFILE_DISKIMAGE) { + if (type == ZFILE_DISKIMAGE || type == ZFILE_EXECUTABLE) { drv = floppyslot_addfile2 (prefs, out, drv, firstdrv, maxdrv); if (drv < 0) break; @@ -22540,7 +22541,11 @@ int dragdrop (HWND hDlg, HDROP hd, struct uae_prefs *prefs, int currentpage) type = zfile_gettype (z); if (type == ZFILE_ROM) { rd = getromdatabyzfile (z); - } + } else if (currentpage == QUICKSTART_ID) { + if (type == ZFILE_UNKNOWN && iszip(z)) { + type = ZFILE_HDF; + } + } // replace with decrunched path but only if // floppy insert and decrunched path is deeper (longer) if (type > 0 && _tcslen(z->name) > _tcslen(file) && drv >= 0) { @@ -22563,7 +22568,7 @@ int dragdrop (HWND hDlg, HDROP hd, struct uae_prefs *prefs, int currentpage) if (drvdrag) { type = ZFILE_DISKIMAGE; - } else if ((zip || harddrive) && type != ZFILE_DISKIMAGE) { + } else if ((zip || harddrive) && type != ZFILE_DISKIMAGE && type != ZFILE_EXECUTABLE) { if (do_filesys_insert (file, cnt)) continue; if (zip) { @@ -22582,6 +22587,7 @@ int dragdrop (HWND hDlg, HDROP hd, struct uae_prefs *prefs, int currentpage) switch (type) { case ZFILE_DISKIMAGE: + case ZFILE_EXECUTABLE: if (currentpage == DISK_ID) { diskswapper_addfile (prefs, file); } else if (currentpage == HARDDISK_ID) { diff --git a/zfile.cpp b/zfile.cpp index 7f368908..c66c2069 100644 --- a/zfile.cpp +++ b/zfile.cpp @@ -329,7 +329,7 @@ int zfile_gettype (struct zfile *z) zfile_fread (buf, 8, 1, z); zfile_fseek (z, -8, SEEK_CUR); if (!memcmp (buf, exeheader, sizeof (buf))) - return ZFILE_DISKIMAGE; + return ZFILE_EXECUTABLE; if (!memcmp (buf, "CAPS", 4)) return ZFILE_DISKIMAGE; if (!memcmp (buf, "SCP", 3)) diff --git a/zfile_archive.cpp b/zfile_archive.cpp index d209a66c..93d3251f 100644 --- a/zfile_archive.cpp +++ b/zfile_archive.cpp @@ -112,6 +112,7 @@ struct zfile *archive_access_select (struct znode *parent, struct zfile *zf, uns int mask = zf->zfdmask; int canhistory = (mask & ZFD_DISKHISTORY) && !(mask & ZFD_CHECKONLY); int getflag = (mask & ZFD_DELAYEDOPEN) ? FILE_DELAYEDOPEN : 0; + int execnt = 0; if (retcode) *retcode = 0; @@ -125,6 +126,7 @@ struct zfile *archive_access_select (struct znode *parent, struct zfile *zf, uns zv = getzvolume (parent, zf, id); if (!zv) return NULL; +retry:; we_have_file = 0; tmphist[0] = 0; zipcnt = 1; @@ -189,8 +191,24 @@ struct zfile *archive_access_select (struct znode *parent, struct zfile *zf, uns ft = ZFILE_CDIMAGE; } } else { - zt = archive_getzfile (zn, id, getflag); - ft = zfile_gettype (zt); + zt = archive_getzfile(zn, id, getflag); + ft = zfile_gettype(zt); + // if more than 1 exe: do not mount as disk image + if (ft == ZFILE_EXECUTABLE) { + if (execnt < 0) { + ft = ZFILE_UNKNOWN; + zfile_fclose(z); + z = NULL; + zfile_fclose(zt); + zt = NULL; + } else { + if (execnt > 0) { + execnt = -1; + goto retry; + } + execnt++; + } + } } if ((select < 0 || ft) && whf > we_have_file) { if (!zt) -- 2.47.3