From 10176338ccd8c156ccd2280efe663afc4d409b2c Mon Sep 17 00:00:00 2001 From: dana Date: Mon, 23 Dec 2024 01:57:13 -0600 Subject: [PATCH] change zip sorting again (#943) * file_io: sort zips with directories again * menu: strip now-redundant .zip extension, make suffix match --- file_io.cpp | 6 ------ menu.cpp | 6 +++++- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/file_io.cpp b/file_io.cpp index c5ba8be..e7f7297 100644 --- a/file_io.cpp +++ b/file_io.cpp @@ -1224,12 +1224,6 @@ struct DirentComp if ((de1.de.d_type == DT_DIR) && (de2.de.d_type != DT_DIR)) return true; if ((de1.de.d_type != DT_DIR) && (de2.de.d_type == DT_DIR)) return false; - if ((de1.de.d_type == DT_DIR) && (de2.de.d_type == DT_DIR)) - { - if (!(de1.flags & DT_EXT_ZIP) && (de2.flags & DT_EXT_ZIP)) return true; - if ((de1.flags & DT_EXT_ZIP) && !(de2.flags & DT_EXT_ZIP)) return false; - } - int len1 = strlen(de1.altname); int len2 = strlen(de2.altname); if ((len1 > 4) && (de1.altname[len1 - 4] == '.')) len1 -= 4; diff --git a/menu.cpp b/menu.cpp index f70ca53..689b610 100644 --- a/menu.cpp +++ b/menu.cpp @@ -7107,6 +7107,10 @@ void PrintDirectory(int expand) { strncpy(s + 1, flist_DirItem(k)->altname+1, len-1); } + else if (flist_DirItem(k)->flags & DT_EXT_ZIP) + { + strncpy(s + 1, flist_DirItem(k)->altname, len-4); // strip .zip extension, see below + } else { strncpy(s + 1, flist_DirItem(k)->altname, len); // display only name @@ -7122,7 +7126,7 @@ void PrintDirectory(int expand) else { if (flist_DirItem(k)->flags & DT_EXT_ZIP) // mark ZIP archive with different suffix - strcpy(&s[22], " "); + strcpy(&s[22], " "); else strcpy(&s[22], " "); }