]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Quickstart disk image/executable drag&drop check, insert in harddrives if archive...
authorToni Wilen <twilen@winuae.net>
Sat, 3 Feb 2024 13:57:35 +0000 (15:57 +0200)
committerToni Wilen <twilen@winuae.net>
Sat, 3 Feb 2024 13:57:35 +0000 (15:57 +0200)
include/zfile.h
main.cpp
od-win32/win32.cpp
od-win32/win32gui.cpp
zfile.cpp
zfile_archive.cpp

index 92fabf8f344b4a2d298f7ac7ac613f87bcc2cd4f..b7f096911228ea217186dbbfe4869f38d3307fff 100644 (file)
@@ -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[];
index 79418a5e92a3457442a2c24a947acb22ecbe4561..86f29743c1cd539f194804e44158acd2632dcce4 100644 (file)
--- 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)++;
        }
index d5caf05885f32eba84996a70246284508c7b0b6d..57de75e9e4ff8fc752cb618f244c134988c1e059 100644 (file)
@@ -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;
index 1569a7bec64ac3deeb7a5342624c9f713a4d6ea2..5ecdb7ffac92a121b0adf9c984c16ea7e5881721 100644 (file)
@@ -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) {
index 7f3689080dec02228acdcece5e24ec1c5e58dcdc..c66c20691b4ce200b55896618534b843d4e7c92f 100644 (file)
--- 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))
index d209a66c52b28b81c31d8ef5db6759dcb9c73998..93d3251f9a6b51cd0626fa7f862610f579a5372a 100644 (file)
@@ -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)