From: Toni Wilen Date: Sat, 6 Sep 2014 11:26:36 +0000 (+0300) Subject: Use ADF volume name when ADF is mounted as a harddrive. X-Git-Tag: 3000~60 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=f459f8139d08e6199a2d8a6e8dd2a57e6a233595;p=francis%2Fwinuae.git Use ADF volume name when ADF is mounted as a harddrive. --- diff --git a/cfgfile.cpp b/cfgfile.cpp index 4b6edb09..ea013d2f 100644 --- a/cfgfile.cpp +++ b/cfgfile.cpp @@ -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); } diff --git a/filesys.cpp b/filesys.cpp index 4b008153..aa8e8e19 100644 --- a/filesys.cpp +++ b/filesys.cpp @@ -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; diff --git a/include/autoconf.h b/include/autoconf.h index e8d635e6..4156558b 100644 --- a/include/autoconf.h +++ b/include/autoconf.h @@ -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); diff --git a/zfile.cpp b/zfile.cpp index ac52058f..02f1e73c 100644 --- 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 { diff --git a/zfile_archive.cpp b/zfile_archive.cpp index 3f26ddbf..0b4a7fa2 100644 --- a/zfile_archive.cpp +++ b/zfile_archive.cpp @@ -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);