mirror of https://github.com/snes9xgit/snes9x.git
Allow unzFindExtension to optionally match the exact filename
This commit is contained in:
parent
ab2da6d913
commit
96fd5c4121
|
@ -967,7 +967,7 @@ static bool8 ReadUPSPatch (Stream *, long, int32 &);
|
||||||
static long ReadInt (Stream *, unsigned);
|
static long ReadInt (Stream *, unsigned);
|
||||||
static bool8 ReadIPSPatch (Stream *, long, int32 &);
|
static bool8 ReadIPSPatch (Stream *, long, int32 &);
|
||||||
#ifdef UNZIP_SUPPORT
|
#ifdef UNZIP_SUPPORT
|
||||||
static int unzFindExtension (unzFile &, const char *, bool restart = TRUE, bool print = TRUE);
|
static int unzFindExtension (unzFile &, const char *, bool restart = TRUE, bool print = TRUE, bool allowExact = FALSE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// deinterleave
|
// deinterleave
|
||||||
|
@ -4188,10 +4188,10 @@ static bool8 ReadIPSPatch (Stream *r, long offset, int32 &rom_size)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef UNZIP_SUPPORT
|
#ifdef UNZIP_SUPPORT
|
||||||
static int unzFindExtension (unzFile &file, const char *ext, bool restart, bool print)
|
static int unzFindExtension (unzFile &file, const char *ext, bool restart, bool print, bool allowExact)
|
||||||
{
|
{
|
||||||
unz_file_info info;
|
unz_file_info info;
|
||||||
int port, l = strlen(ext);
|
int port, l = strlen(ext), e = allowExact ? 0 : 1;
|
||||||
|
|
||||||
if (restart)
|
if (restart)
|
||||||
port = unzGoToFirstFile(file);
|
port = unzGoToFirstFile(file);
|
||||||
|
@ -4206,7 +4206,7 @@ static int unzFindExtension (unzFile &file, const char *ext, bool restart, bool
|
||||||
unzGetCurrentFileInfo(file, &info, name, 128, NULL, 0, NULL, 0);
|
unzGetCurrentFileInfo(file, &info, name, 128, NULL, 0, NULL, 0);
|
||||||
len = strlen(name);
|
len = strlen(name);
|
||||||
|
|
||||||
if (len >= l + 1 && name[len - l - 1] == '.' && strcasecmp(name + len - l, ext) == 0 && unzOpenCurrentFile(file) == UNZ_OK)
|
if (len >= l + e && name[len - l - 1] == '.' && strcasecmp(name + len - l, ext) == 0 && unzOpenCurrentFile(file) == UNZ_OK)
|
||||||
{
|
{
|
||||||
if (print)
|
if (print)
|
||||||
printf("Using patch %s", name);
|
printf("Using patch %s", name);
|
||||||
|
|
8
msu1.cpp
8
msu1.cpp
|
@ -206,10 +206,10 @@ size_t partial_samples;
|
||||||
int16 *bufPos, *bufBegin, *bufEnd;
|
int16 *bufPos, *bufBegin, *bufEnd;
|
||||||
|
|
||||||
#ifdef UNZIP_SUPPORT
|
#ifdef UNZIP_SUPPORT
|
||||||
static int unzFindExtension(unzFile &file, const char *ext, bool restart = TRUE, bool print = TRUE)
|
static int unzFindExtension(unzFile &file, const char *ext, bool restart = TRUE, bool print = TRUE, bool allowExact = FALSE)
|
||||||
{
|
{
|
||||||
unz_file_info info;
|
unz_file_info info;
|
||||||
int port, l = strlen(ext);
|
int port, l = strlen(ext), e = allowExact ? 0 : 1;
|
||||||
|
|
||||||
if (restart)
|
if (restart)
|
||||||
port = unzGoToFirstFile(file);
|
port = unzGoToFirstFile(file);
|
||||||
|
@ -224,7 +224,7 @@ static int unzFindExtension(unzFile &file, const char *ext, bool restart = TRUE,
|
||||||
unzGetCurrentFileInfo(file, &info, name, 128, NULL, 0, NULL, 0);
|
unzGetCurrentFileInfo(file, &info, name, 128, NULL, 0, NULL, 0);
|
||||||
len = strlen(name);
|
len = strlen(name);
|
||||||
|
|
||||||
if (len >= l && strcasecmp(name + len - l, ext) == 0 && unzOpenCurrentFile(file) == UNZ_OK)
|
if (len >= l + e && strcasecmp(name + len - l, ext) == 0 && unzOpenCurrentFile(file) == UNZ_OK)
|
||||||
{
|
{
|
||||||
if (print)
|
if (print)
|
||||||
printf("Using msu file %s", name);
|
printf("Using msu file %s", name);
|
||||||
|
@ -267,7 +267,7 @@ STREAM S9xMSU1OpenFile(char *msu_ext)
|
||||||
|
|
||||||
if (unzFile)
|
if (unzFile)
|
||||||
{
|
{
|
||||||
int port = unzFindExtension(unzFile, msu_ext);
|
int port = unzFindExtension(unzFile, msu_ext, true, true, true);
|
||||||
if (port == UNZ_OK)
|
if (port == UNZ_OK)
|
||||||
{
|
{
|
||||||
printf(" in %s.\n", zip_filename);
|
printf(" in %s.\n", zip_filename);
|
||||||
|
|
Loading…
Reference in New Issue