unpacked: let archivers "abandon" the archive instead of closing it.

This lets you preserve the PHYSFS_Io in case of error during archive opening.
This commit is contained in:
Ryan C. Gordon 2017-07-21 19:01:41 -04:00
parent 91a19982ca
commit 3c9351c0ad
9 changed files with 17 additions and 7 deletions

View File

@ -78,7 +78,7 @@ static void *GRP_openArchive(PHYSFS_Io *io, const char *name, int forWriting)
if (!grpLoadEntries(io, count, unpkarc))
{
UNPK_closeArchive(unpkarc);
UNPK_abandonArchive(unpkarc);
return NULL;
} /* if */

View File

@ -77,7 +77,7 @@ static void *HOG_openArchive(PHYSFS_Io *io, const char *name, int forWriting)
if (!hogLoadEntries(io, unpkarc))
{
UNPK_closeArchive(unpkarc);
UNPK_abandonArchive(unpkarc);
return NULL;
} /* if */

View File

@ -315,7 +315,7 @@ static void *ISO9660_openArchive(PHYSFS_Io *io, const char *filename, int forWri
if (!iso9660LoadEntries(io, joliet, "", rootpos, rootpos + len, unpkarc))
{
UNPK_closeArchive(unpkarc);
UNPK_abandonArchive(unpkarc);
return NULL;
} /* if */

View File

@ -72,7 +72,7 @@ static void *MVL_openArchive(PHYSFS_Io *io, const char *name, int forWriting)
if (!mvlLoadEntries(io, count, unpkarc))
{
UNPK_closeArchive(unpkarc);
UNPK_abandonArchive(unpkarc);
return NULL;
} /* if */

View File

@ -88,7 +88,7 @@ static void *QPAK_openArchive(PHYSFS_Io *io, const char *name, int forWriting)
if (!qpakLoadEntries(io, count, unpkarc))
{
UNPK_closeArchive(unpkarc);
UNPK_abandonArchive(unpkarc);
return NULL;
} /* if */

View File

@ -98,7 +98,7 @@ static void *SLB_openArchive(PHYSFS_Io *io, const char *name, int forWriting)
if (!slbLoadEntries(io, count, unpkarc))
{
UNPK_closeArchive(unpkarc);
UNPK_abandonArchive(unpkarc);
return NULL;
} /* if */

View File

@ -51,6 +51,15 @@ void UNPK_closeArchive(void *opaque)
} /* if */
} /* UNPK_closeArchive */
void UNPK_abandonArchive(void *opaque)
{
UNPKinfo *info = ((UNPKinfo *) opaque);
if (info)
{
info->io = NULL;
UNPK_closeArchive(info);
} /* if */
} /* UNPK_abandonArchive */
static PHYSFS_sint64 UNPK_read(PHYSFS_Io *io, void *buffer, PHYSFS_uint64 len)
{

View File

@ -97,7 +97,7 @@ static void *WAD_openArchive(PHYSFS_Io *io, const char *name, int forWriting)
if (!wadLoadEntries(io, count, unpkarc))
{
UNPK_closeArchive(unpkarc);
UNPK_abandonArchive(unpkarc);
return NULL;
} /* if */

View File

@ -342,6 +342,7 @@ int __PHYSFS_readAll(PHYSFS_Io *io, void *buf, const PHYSFS_uint64 len);
/* These are shared between some archivers. */
void UNPK_abandonArchive(void *opaque);
void UNPK_closeArchive(void *opaque);
void *UNPK_openArchive(PHYSFS_Io *io);
void *UNPK_addEntry(void *opaque, char *name, const int isdir,