]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Use ADF volume name when ADF is mounted as a harddrive.
authorToni Wilen <twilen@winuae.net>
Sat, 6 Sep 2014 11:26:36 +0000 (14:26 +0300)
committerToni Wilen <twilen@winuae.net>
Sat, 6 Sep 2014 11:26:36 +0000 (14:26 +0300)
cfgfile.cpp
filesys.cpp
include/autoconf.h
zfile.cpp
zfile_archive.cpp

index 4b6edb09f085cc683e099c331487d7c1b16abca3..ea013d2f3708fe34308868e0d84d7b247bf692cd 100644 (file)
@@ -3007,8 +3007,8 @@ struct uaedev_config_data *add_filesys_config (struct uae_prefs *p, int index, s
                return NULL;
 
        memcpy (&uci->ci, ci, sizeof (struct uaedev_config_info));
-       validatedevicename (uci->ci.devname);
-       validatevolumename (uci->ci.volname);
+       validatedevicename (uci->ci.devname, NULL);
+       validatevolumename (uci->ci.volname, NULL);
        if (!uci->ci.devname[0] && ci->type != UAEDEV_CD && ci->type != UAEDEV_TAPE) {
                TCHAR base[32];
                TCHAR base2[32];
@@ -3027,10 +3027,10 @@ struct uaedev_config_data *add_filesys_config (struct uae_prefs *p, int index, s
                        }
                }
                _tcscpy (uci->ci.devname, base2);
-               validatedevicename (uci->ci.devname);
+               validatedevicename (uci->ci.devname, NULL);
        }
        if (ci->type == UAEDEV_DIR) {
-               TCHAR *s = filesys_createvolname (uci->ci.volname, uci->ci.rootdir, _T("Harddrive"));
+               TCHAR *s = filesys_createvolname (uci->ci.volname, uci->ci.rootdir, NULL, _T("Harddrive"));
                _tcscpy (uci->ci.volname, s);
                xfree (s);
        }
index 4b008153e86e592b2645a2c5646d0582ed011b22..aa8e8e19f06ac1fe73230f8e3163f1ca783cad84 100644 (file)
@@ -41,6 +41,7 @@
 #include "uaeserial.h"
 #include "fsdb.h"
 #include "zfile.h"
+#include "zarchive.h"
 #include "gui.h"
 #include "gayle.h"
 #include "savestate.h"
@@ -447,23 +448,27 @@ static void fixcharset (TCHAR *s)
        au_fs_copy (s, strlen (tmp) + 1, tmp);
 }
 
-TCHAR *validatevolumename (TCHAR *s)
+TCHAR *validatevolumename (TCHAR *s, const TCHAR *def)
 {
        stripsemicolon (s);
        fixcharset (s);
        striplength (s, 30);
+       if (_tcslen(s) == 0 && def)
+               _tcscpy(s, def);
        return s;
 }
-TCHAR *validatedevicename (TCHAR *s)
+TCHAR *validatedevicename (TCHAR *s, const TCHAR *def)
 {
        stripsemicolon (s);
        stripspace (s);
        fixcharset (s);
        striplength (s, 30);
+       if (_tcslen(s) == 0 && def)
+               _tcscpy(s, def);
        return s;
 }
 
-TCHAR *filesys_createvolname (const TCHAR *volname, const TCHAR *rootdir, const TCHAR *def)
+TCHAR *filesys_createvolname (const TCHAR *volname, const TCHAR *rootdir, struct zvolume *zv, const TCHAR *def)
 {
        TCHAR *nvol = NULL;
        int i, archivehd;
@@ -475,6 +480,12 @@ TCHAR *filesys_createvolname (const TCHAR *volname, const TCHAR *rootdir, const
        else if (my_existsdir (rootdir))
                archivehd = 0;
 
+       if (zv && zv->volumename && _tcslen(zv->volumename) > 0) {
+               nvol = my_strdup(zv->volumename);
+               validatevolumename (nvol, def);
+               return nvol;
+       }
+
        if ((!volname || _tcslen (volname) == 0) && rootdir && archivehd >= 0) {
                p = my_strdup (rootdir);
                for (i = _tcslen (p) - 1; i >= 0; i--) {
@@ -510,7 +521,7 @@ TCHAR *filesys_createvolname (const TCHAR *volname, const TCHAR *rootdir, const
                else
                        nvol = my_strdup (_T(""));
        }
-       validatevolumename (nvol);
+       validatevolumename (nvol, def);
        xfree (p);
        return nvol;
 }
@@ -620,7 +631,7 @@ static int set_filesys_unit_1 (int nr, struct uaedev_config_info *ci)
                        if (set_filesys_volume (c.rootdir, &flags, &c.readonly, &emptydrive, &ui->zarchive) < 0)
                                return -1;
                }
-               ui->volname = filesys_createvolname (c.volname, c.rootdir, _T("harddrive"));
+               ui->volname = filesys_createvolname (c.volname, c.rootdir, ui->zarchive, _T("harddrive"));
                ui->volflags = flags;
        } else {
                ui->unit_type = UNIT_FILESYSTEM;
@@ -1802,7 +1813,7 @@ static uae_u32 filesys_media_change_reply (TrapContext *ctx, int mode)
                                if (emptydrive)
                                        return 0;
                                xfree (u->ui.volname);
-                               ui->volname = u->ui.volname = filesys_createvolname (u->mount_volume, u->mount_rootdir, _T("removable"));
+                               ui->volname = u->ui.volname = filesys_createvolname (u->mount_volume, u->mount_rootdir, u->zarchive, _T("removable"));
 #ifdef RETROPLATFORM
                                rp_harddrive_image_change (nr, u->mount_readonly, u->mount_rootdir);
 #endif
@@ -1900,7 +1911,7 @@ int filesys_media_change (const TCHAR *rootdir, int inserted, struct uaedev_conf
                        }
                }
                if (!volptr) {
-                       volptr = filesys_createvolname (NULL, rootdir, _T("removable"));
+                       volptr = filesys_createvolname (NULL, rootdir, NULL, _T("removable"));
                        _tcscpy (volname, volptr);
                        xfree (volptr);
                        volptr = volname;
index e8d635e682bb0529b4e62fb852dc6b5d571e11ca..4156558b236a65a79ee41cb8f96ad675b73b859a 100644 (file)
@@ -64,14 +64,14 @@ extern int add_filesys_unitconfig (struct uae_prefs *p, int index, TCHAR *error)
 extern int get_filesys_unitconfig (struct uae_prefs *p, int index, struct mountedinfo*);
 extern int kill_filesys_unitconfig (struct uae_prefs *p, int nr);
 extern int move_filesys_unitconfig (struct uae_prefs *p, int nr, int to);
-extern TCHAR *validatedevicename (TCHAR *s);
-extern TCHAR *validatevolumename (TCHAR *s);
+extern TCHAR *validatedevicename (TCHAR *s, const TCHAR *def);
+extern TCHAR *validatevolumename (TCHAR *s, const TCHAR *def);
 
 int filesys_insert (int nr, const TCHAR *volume, const TCHAR *rootdir, bool readonly, int flags);
 int filesys_eject (int nr);
 int filesys_media_change (const TCHAR *rootdir, int inserted, struct uaedev_config_data *uci);
 
-extern TCHAR *filesys_createvolname (const TCHAR *volname, const TCHAR *rootdir, const TCHAR *def);
+extern TCHAR *filesys_createvolname (const TCHAR *volname, const TCHAR *rootdir, struct zvolume *zv, const TCHAR *def);
 extern int target_get_volume_name (struct uaedev_mount_info *mtinf, const TCHAR *volumepath, TCHAR *volumename, int size, bool inserted, bool fullcheck);
 
 extern int sprintf_filesys_unit (TCHAR *buffer, int num);
index ac52058fb452f124a72ddf632545bfa0f6a113b0..02f1e73c1503423d22f3ec2a2f8ebda6d642eeff 100644 (file)
--- a/zfile.cpp
+++ b/zfile.cpp
@@ -3186,7 +3186,8 @@ void zfile_fclose_archive (struct zvolume *zv)
                        v = v->next;
                }
        }
-       xfree (zv);
+       xfree(zv->volumename);
+       xfree(zv);
 }
 
 struct zdirectory {
index 3f26ddbf92946154361f7282f25895a1d8fc3011..0b4a7fa27b0a2e2fb7e84b92f22ce73ddf6152f3 100644 (file)
@@ -1343,7 +1343,6 @@ struct zvolume *archive_directory_adf (struct znode *parent, struct zfile *z)
 {
        struct zvolume *zv;
        struct adfhandle *adf;
-       TCHAR *volname = NULL;
        TCHAR name[MAX_DPATH];
        int gotroot = 0;
 
@@ -1412,10 +1411,10 @@ struct zvolume *archive_directory_adf (struct znode *parent, struct zfile *z)
                        goto fail;
                adf->blocksize = bs;
                adf->highblock = adf->size / adf->blocksize;
-               volname = getBSTR (adf->block + adf->blocksize - 20 * 4);
                zv = zvolume_alloc (z, ArchiveFormatADF, NULL, NULL);
                zv->method = ArchiveFormatADF;
                zv->handle = adf;
+               zv->volumename = getBSTR (adf->block + adf->blocksize - 20 * 4);
 
                name[0] = 0;
                recurseadf (&zv->root, adf->rootblock, name);
@@ -1467,8 +1466,6 @@ struct zvolume *archive_directory_adf (struct znode *parent, struct zfile *z)
                goto fail;
        }
 
-
-       xfree (volname);
        return zv;
 fail:
        xfree (adf);