unpacked: let archivers "abandon" the archive instead of closing it.
authorRyan C. Gordon <icculus@icculus.org>
Fri, 21 Jul 2017 19:01:41 -0400
changeset 1497 b9d771d6805f
parent 1496 6e1c8ff88482
child 1498 5977294d8e4b
unpacked: let archivers "abandon" the archive instead of closing it. This lets you preserve the PHYSFS_Io in case of error during archive opening.
src/archiver_grp.c
src/archiver_hog.c
src/archiver_iso9660.c
src/archiver_mvl.c
src/archiver_qpak.c
src/archiver_slb.c
src/archiver_unpacked.c
src/archiver_wad.c
src/physfs_internal.h
--- a/src/archiver_grp.c	Fri Jul 21 13:56:21 2017 -0400
+++ b/src/archiver_grp.c	Fri Jul 21 19:01:41 2017 -0400
@@ -78,7 +78,7 @@
 
     if (!grpLoadEntries(io, count, unpkarc))
     {
-        UNPK_closeArchive(unpkarc);
+        UNPK_abandonArchive(unpkarc);
         return NULL;
     } /* if */
 
--- a/src/archiver_hog.c	Fri Jul 21 13:56:21 2017 -0400
+++ b/src/archiver_hog.c	Fri Jul 21 19:01:41 2017 -0400
@@ -77,7 +77,7 @@
 
     if (!hogLoadEntries(io, unpkarc))
     {
-        UNPK_closeArchive(unpkarc);
+        UNPK_abandonArchive(unpkarc);
         return NULL;
     } /* if */
 
--- a/src/archiver_iso9660.c	Fri Jul 21 13:56:21 2017 -0400
+++ b/src/archiver_iso9660.c	Fri Jul 21 19:01:41 2017 -0400
@@ -315,7 +315,7 @@
 
     if (!iso9660LoadEntries(io, joliet, "", rootpos, rootpos + len, unpkarc))
     {
-        UNPK_closeArchive(unpkarc);
+        UNPK_abandonArchive(unpkarc);
         return NULL;
     } /* if */
 
--- a/src/archiver_mvl.c	Fri Jul 21 13:56:21 2017 -0400
+++ b/src/archiver_mvl.c	Fri Jul 21 19:01:41 2017 -0400
@@ -72,7 +72,7 @@
 
     if (!mvlLoadEntries(io, count, unpkarc))
     {
-        UNPK_closeArchive(unpkarc);
+        UNPK_abandonArchive(unpkarc);
         return NULL;
     } /* if */
 
--- a/src/archiver_qpak.c	Fri Jul 21 13:56:21 2017 -0400
+++ b/src/archiver_qpak.c	Fri Jul 21 19:01:41 2017 -0400
@@ -88,7 +88,7 @@
 
     if (!qpakLoadEntries(io, count, unpkarc))
     {
-        UNPK_closeArchive(unpkarc);
+        UNPK_abandonArchive(unpkarc);
         return NULL;
     } /* if */
 
--- a/src/archiver_slb.c	Fri Jul 21 13:56:21 2017 -0400
+++ b/src/archiver_slb.c	Fri Jul 21 19:01:41 2017 -0400
@@ -98,7 +98,7 @@
 
     if (!slbLoadEntries(io, count, unpkarc))
     {
-        UNPK_closeArchive(unpkarc);
+        UNPK_abandonArchive(unpkarc);
         return NULL;
     } /* if */
 
--- a/src/archiver_unpacked.c	Fri Jul 21 13:56:21 2017 -0400
+++ b/src/archiver_unpacked.c	Fri Jul 21 19:01:41 2017 -0400
@@ -51,6 +51,15 @@
     } /* 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)
 {
--- a/src/archiver_wad.c	Fri Jul 21 13:56:21 2017 -0400
+++ b/src/archiver_wad.c	Fri Jul 21 19:01:41 2017 -0400
@@ -97,7 +97,7 @@
 
     if (!wadLoadEntries(io, count, unpkarc))
     {
-        UNPK_closeArchive(unpkarc);
+        UNPK_abandonArchive(unpkarc);
         return NULL;
     } /* if */
 
--- a/src/physfs_internal.h	Fri Jul 21 13:56:21 2017 -0400
+++ b/src/physfs_internal.h	Fri Jul 21 19:01:41 2017 -0400
@@ -342,6 +342,7 @@
 
 /* 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,