Better ZIP sorting, add <zip> suffix (#900)

This commit is contained in:
TpaBkaY
2024-05-17 09:27:26 +03:00
committed by GitHub
parent f8949320ba
commit a2941ae27e
3 changed files with 17 additions and 1 deletions

View File

@@ -1224,6 +1224,12 @@ 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;
@@ -1465,6 +1471,8 @@ int ScanDirectory(char* path, int mode, const char *extension, int options, cons
}
#endif
struct dirent64 _de = {};
int isZip = 0;
if (z)
{
mz_zip_reader_get_filename(z, i, &_de.d_name[0], sizeof(_de.d_name));
@@ -1634,6 +1642,7 @@ int ScanDirectory(char* path, int mode, const char *extension, int options, cons
{
// Fake that zip-file is a directory.
de->d_type = DT_DIR;
isZip = 1;
found = 1;
}
if (!found && is_minimig() && !memcmp(extension, "HDF", 3))
@@ -1681,6 +1690,8 @@ int ScanDirectory(char* path, int mode, const char *extension, int options, cons
direntext_t dext;
memset(&dext, 0, sizeof(dext));
memcpy(&dext.de, de, sizeof(dext.de));
if (isZip)
dext.flags |= DT_EXT_ZIP;
get_display_name(&dext, extension, options);
DirItem.push_back(dext);
}

View File

@@ -30,6 +30,8 @@ struct direntext_t
{
dirent de;
int cookie;
#define DT_EXT_ZIP 0x1
unsigned int flags;
char datecode[16];
char altname[256];
};

View File

@@ -7120,7 +7120,10 @@ void PrintDirectory(int expand)
}
else
{
strcpy(&s[22], " <DIR>");
if (flist_DirItem(k)->flags & DT_EXT_ZIP) // mark ZIP archive with different suffix
strcpy(&s[22], " <zip>");
else
strcpy(&s[22], " <DIR>");
}
len2 = 0;
}