Просмотр исходного кода

Changed DirFunctions struct a little.

Ryan C. Gordon 23 лет назад
Родитель
Сommit
3ae1f1fa80
4 измененных файлов с 31 добавлено и 30 удалено
  1. 10 12
      archivers/dir.c
  2. 10 8
      archivers/grp.c
  3. 9 10
      archivers/zip.c
  4. 2 0
      physfs_internal.h

+ 10 - 12
archivers/dir.c

@@ -46,6 +46,15 @@ static int DIR_mkdir(DirHandle *h, const char *name);
 static void DIR_dirClose(DirHandle *h);
 
 
+const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_DIR =
+{
+    "",
+    "non-archive directory I/O",
+    "Ryan C. Gordon <icculus@clutteredmind.org>",
+    "http://icculus.org/physfs/",
+};
+
+
 static const FileFunctions __PHYSFS_FileFunctions_DIR =
 {
     DIR_read,       /* read() method       */
@@ -72,6 +81,7 @@ static const FileFunctions __PHYSFS_FileFunctions_DIRW =
 
 const DirFunctions __PHYSFS_DirFunctions_DIR =
 {
+    &__PHYSFS_ArchiveInfo_DIR,
     DIR_isArchive,          /* isArchive() method      */
     DIR_openArchive,        /* openArchive() method    */
     DIR_enumerateFiles,     /* enumerateFiles() method */
@@ -88,18 +98,6 @@ const DirFunctions __PHYSFS_DirFunctions_DIR =
 };
 
 
-/* This doesn't get listed, since it's technically not an archive... */
-#if 0
-const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_DIR =
-{
-    "DIR",
-    "non-archive directory I/O",
-    "Ryan C. Gordon <icculus@clutteredmind.org>",
-    "http://www.icculus.org/physfs/",
-};
-#endif
-
-
 static PHYSFS_sint64 DIR_read(FileHandle *handle, void *buffer,
                               PHYSFS_uint32 objSize, PHYSFS_uint32 objCount)
 {

+ 10 - 8
archivers/grp.c

@@ -90,6 +90,15 @@ static int GRP_isSymLink(DirHandle *h, const char *name);
 static PHYSFS_sint64 GRP_getLastModTime(DirHandle *h, const char *name);
 static FileHandle *GRP_openRead(DirHandle *h, const char *name);
 
+const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_GRP =
+{
+    "GRP",
+    "Build engine Groupfile format",
+    "Ryan C. Gordon <icculus@clutteredmind.org>",
+    "http://icculus.org/physfs/",
+};
+
+
 static const FileFunctions __PHYSFS_FileFunctions_GRP =
 {
     GRP_read,       /* read() method       */
@@ -104,6 +113,7 @@ static const FileFunctions __PHYSFS_FileFunctions_GRP =
 
 const DirFunctions __PHYSFS_DirFunctions_GRP =
 {
+    &__PHYSFS_ArchiveInfo_GRP,
     GRP_isArchive,          /* isArchive() method      */
     GRP_openArchive,        /* openArchive() method    */
     GRP_enumerateFiles,     /* enumerateFiles() method */
@@ -119,14 +129,6 @@ const DirFunctions __PHYSFS_DirFunctions_GRP =
     GRP_dirClose            /* dirClose() method       */
 };
 
-const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_GRP =
-{
-    "GRP",
-    "Build engine Groupfile format",
-    "Ryan C. Gordon <icculus@clutteredmind.org>",
-    "http://www.icculus.org/physfs/",
-};
-
 
 
 static void GRP_dirClose(DirHandle *h)

+ 9 - 10
archivers/zip.c

@@ -141,10 +141,17 @@ static int ZIP_isSymLink(DirHandle *h, const char *name);
 static PHYSFS_sint64 ZIP_getLastModTime(DirHandle *h, const char *name);
 static FileHandle *ZIP_openRead(DirHandle *h, const char *filename);
 static void ZIP_dirClose(DirHandle *h);
-
 static int zip_resolve(void *in, ZIPinfo *info, ZIPentry *entry);
 
 
+const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_ZIP =
+{
+    "ZIP",
+    "PkZip/WinZip/Info-Zip compatible",
+    "Ryan C. Gordon <icculus@clutteredmind.org>",
+    "http://icculus.org/physfs/",
+};
+
 static const FileFunctions __PHYSFS_FileFunctions_ZIP =
 {
     ZIP_read,       /* read() method       */
@@ -159,6 +166,7 @@ static const FileFunctions __PHYSFS_FileFunctions_ZIP =
 
 const DirFunctions __PHYSFS_DirFunctions_ZIP =
 {
+    &__PHYSFS_ArchiveInfo_ZIP,
     ZIP_isArchive,          /* isArchive() method      */
     ZIP_openArchive,        /* openArchive() method    */
     ZIP_enumerateFiles,     /* enumerateFiles() method */
@@ -174,15 +182,6 @@ const DirFunctions __PHYSFS_DirFunctions_ZIP =
     ZIP_dirClose            /* dirClose() method       */
 };
 
-const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_ZIP =
-{
-    "ZIP",
-    "PkZip/WinZip/Info-Zip compatible",
-    "Ryan C. Gordon <icculus@clutteredmind.org>",
-    "http://www.icculus.org/physfs/",
-};
-
-
 
 /*
  * Wrap all zlib calls in this, so the physfs error state is set appropriately.

+ 2 - 0
physfs_internal.h

@@ -125,6 +125,8 @@ typedef struct __PHYSFS_DIRHANDLE__
  */
 typedef struct __PHYSFS_DIRFUNCTIONS__
 {
+    const PHYSFS_ArchiveInfo *info;
+
         /*
          * Returns non-zero if (filename) is a valid archive that this
          *  driver can handle. This filename is in platform-dependent