Support for * wildcard.

This commit is contained in:
sorgelig
2019-01-25 07:12:50 +08:00
parent 9edfb310b5
commit 07f4d0c5b3
3 changed files with 17 additions and 23 deletions

View File

@@ -1184,30 +1184,23 @@ int ScanDirectory(char* path, int mode, const char *extension, int options, cons
found = !strcasecmp(de->d_name + strlen(de->d_name) - 4, ".iso");
}
while(!found && *ext)
char *fext = strrchr(de->d_name, '.');
while(!found && *ext && fext)
{
char e[5];
memcpy(e+1, ext, 3);
if (e[3] == 0x20)
char e[4];
memcpy(e, ext, 3);
if (e[2] == ' ')
{
e[3] = 0;
if (e[2] == 0x20)
{
e[2] = 0;
}
e[2] = 0;
if (e[1] == ' ') e[1] = 0;
}
e[0] = '.';
e[4] = 0;
int l = strlen(e);
if (len > l)
e[3] = 0;
found = 1;
for (int i = 0; i < 3; i++)
{
char *p = de->d_name + len - l;
found = 1;
for (int i = 0; i < l; i++)
{
if (e[i] == '?') continue;
if (tolower(e[i]) != tolower(p[i])) found = 0;
}
if (e[i] == '*') break;
if (e[i] == '?' && fext[i+1]) continue;
if (tolower(e[i]) != tolower(fext[i + 1])) found = 0;
}
if (found) break;

View File

@@ -1163,7 +1163,7 @@ void HandleUI(void)
}
else
{
static char ext[13];
static char ext[256];
p = user_io_8bit_get_string(1);
uint32_t entry = 0;
@@ -1180,7 +1180,7 @@ void HandleUI(void)
{
opensave = (p[1] == 'S');
substrcpy(ext, p, 1);
while (strlen(ext) < 3) strcat(ext, " ");
while (strlen(ext) % 3) strcat(ext, " ");
SelectFile(ext, SCANO_DIR, MENU_8BIT_MAIN_FILE_SELECTED, MENU_8BIT_MAIN1);
}
else if (p[0] == 'S')
@@ -1188,7 +1188,7 @@ void HandleUI(void)
drive_num = 0;
if (p[1] >= '0' && p[1] <= '3') drive_num = p[1] - '0';
substrcpy(ext, p, 1);
while (strlen(ext) < 3) strcat(ext, " ");
while (strlen(ext) % 3) strcat(ext, " ");
SelectFile(ext, SCANO_DIR | SCANO_UMOUNT, MENU_8BIT_MAIN_IMAGE_SELECTED, MENU_8BIT_MAIN1);
}
else if (p[0] == 'O')

View File

@@ -2583,6 +2583,7 @@ unsigned char user_io_ext_idx(char *name, char* ext)
int found = 1;
for (int i = 0; i < 3; i++)
{
if (ext[i] == '*') break;
if (ext[i] != '?' && (toupper(ext[i]) != toupper(e[i]))) found = 0;
}