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

Moved supportsSymlinks into PHYSFS_ArchiveInfo.

Ryan C. Gordon 13 лет назад
Родитель
Сommit
ada24e9c5d

+ 1 - 1
src/archiver_dir.c

@@ -185,8 +185,8 @@ const PHYSFS_Archiver __PHYSFS_Archiver_DIR =
         "Non-archive, direct filesystem I/O",
         "Ryan C. Gordon <icculus@icculus.org>",
         "http://icculus.org/physfs/",
+        1,  /* supportsSymlinks */
     },
-    1,  /* supportsSymlinks */
     DIR_openArchive,        /* openArchive() method    */
     DIR_enumerateFiles,     /* enumerateFiles() method */
     DIR_openRead,           /* openRead() method       */

+ 1 - 1
src/archiver_grp.c

@@ -93,8 +93,8 @@ const PHYSFS_Archiver __PHYSFS_Archiver_GRP =
         "Build engine Groupfile format",
         "Ryan C. Gordon <icculus@icculus.org>",
         "http://icculus.org/physfs/",
+        0,  /* supportsSymlinks */
     },
-    0,  /* supportsSymlinks */
     GRP_openArchive,        /* openArchive() method    */
     UNPK_enumerateFiles,    /* enumerateFiles() method */
     UNPK_openRead,          /* openRead() method       */

+ 1 - 1
src/archiver_hog.c

@@ -99,8 +99,8 @@ const PHYSFS_Archiver __PHYSFS_Archiver_HOG =
         "Descent I/II HOG file format",
         "Bradley Bell <btb@icculus.org>",
         "http://icculus.org/physfs/",
+        0,  /* supportsSymlinks */
     },
-    0,  /* supportsSymlinks */
     HOG_openArchive,         /* openArchive() method    */
     UNPK_enumerateFiles,     /* enumerateFiles() method */
     UNPK_openRead,           /* openRead() method       */

+ 1 - 1
src/archiver_iso9660.c

@@ -951,8 +951,8 @@ const PHYSFS_Archiver __PHYSFS_Archiver_ISO9660 =
         "ISO9660 image file",
         "Christoph Nelles <evilazrael@evilazrael.de>",
         "http://www.evilazrael.de/",
+        0,  /* supportsSymlinks */
     },
-    0,  /* supportsSymlinks */
     ISO9660_openArchive,        /* openArchive() method    */
     ISO9660_enumerateFiles,     /* enumerateFiles() method */
     ISO9660_openRead,           /* openRead() method       */

+ 1 - 1
src/archiver_lzma.c

@@ -684,8 +684,8 @@ const PHYSFS_Archiver __PHYSFS_Archiver_LZMA =
         "LZMA (7zip) format",
         "Dennis Schridde <devurandom@gmx.net>",
         "http://icculus.org/physfs/",
+        0,  /* supportsSymlinks */
     },
-    0,  /* supportsSymlinks */
     LZMA_openArchive,        /* openArchive() method    */
     LZMA_enumerateFiles,     /* enumerateFiles() method */
     LZMA_openRead,           /* openRead() method       */

+ 1 - 1
src/archiver_mvl.c

@@ -86,8 +86,8 @@ const PHYSFS_Archiver __PHYSFS_Archiver_MVL =
         "Descent II Movielib format",
         "Bradley Bell <btb@icculus.org>",
         "http://icculus.org/physfs/",
+        0,  /* supportsSymlinks */
     },
-    0,  /* supportsSymlinks */
     MVL_openArchive,        /* openArchive() method    */
     UNPK_enumerateFiles,     /* enumerateFiles() method */
     UNPK_openRead,           /* openRead() method       */

+ 1 - 1
src/archiver_qpak.c

@@ -102,8 +102,8 @@ const PHYSFS_Archiver __PHYSFS_Archiver_QPAK =
         "Quake I/II format",
         "Ryan C. Gordon <icculus@icculus.org>",
         "http://icculus.org/physfs/",
+        0,  /* supportsSymlinks */
     },
-    0,  /* supportsSymlinks */
     QPAK_openArchive,       /* openArchive() method    */
     UNPK_enumerateFiles,    /* enumerateFiles() method */
     UNPK_openRead,          /* openRead() method       */

+ 1 - 1
src/archiver_slb.c

@@ -107,8 +107,8 @@ const PHYSFS_Archiver __PHYSFS_Archiver_SLB =
         "I-War / Independence War Slab file",
         "Aleksi Nurmi <aleksi.nurmi@gmail.com>",
         "http://bitbucket.org/ahnurmi/",
+        0,  /* supportsSymlinks */
     },
-    0,  /* supportsSymlinks */
     SLB_openArchive,        /* openArchive() method    */
     UNPK_enumerateFiles,    /* enumerateFiles() method */
     UNPK_openRead,          /* openRead() method       */

+ 1 - 1
src/archiver_wad.c

@@ -110,8 +110,8 @@ const PHYSFS_Archiver __PHYSFS_Archiver_WAD =
         "DOOM engine format",
         "Travis Wells <traviswells@mchsi.com>",
         "http://www.3dmm2.com/doom/",
+        0,  /* supportsSymlinks */
     },
-    0,  /* supportsSymlinks */
     WAD_openArchive,        /* openArchive() method    */
     UNPK_enumerateFiles,     /* enumerateFiles() method */
     UNPK_openRead,           /* openRead() method       */

+ 1 - 1
src/archiver_zip.c

@@ -1697,8 +1697,8 @@ const PHYSFS_Archiver __PHYSFS_Archiver_ZIP =
         "PkZip/WinZip/Info-Zip compatible",
         "Ryan C. Gordon <icculus@icculus.org>",
         "http://icculus.org/physfs/",
+        1,  /* supportsSymlinks */
     },
-    1,  /* supportsSymlinks */
     ZIP_openArchive,        /* openArchive() method    */
     ZIP_enumerateFiles,     /* enumerateFiles() method */
     ZIP_openRead,           /* openRead() method       */

+ 2 - 1
src/physfs.c

@@ -1423,6 +1423,7 @@ static int doRegisterArchiver(const PHYSFS_Archiver *_archiver)
     CPYSTR(description);
     CPYSTR(author);
     CPYSTR(url);
+    info->supportsSymlinks = _archiver->info.supportsSymlinks;
     #undef CPYSTR
 
     ptr = allocator.Realloc(archiveInfo, len);
@@ -2316,7 +2317,7 @@ void PHYSFS_enumerateFilesCallback(const char *_fname,
 
             else if (verifyPath(i, &arcfname, 0))
             {
-                if ((!allowSymLinks) && (i->funcs->supportsSymlinks))
+                if ((!allowSymLinks) && (i->funcs->info.supportsSymlinks))
                 {
                     filterdata.dirhandle = i;
                     i->funcs->enumerateFiles(i->opaque, arcfname,

+ 2 - 7
src/physfs.h

@@ -408,6 +408,7 @@ typedef struct PHYSFS_ArchiveInfo
     const char *description; /**< Human-readable archive description. */
     const char *author;      /**< Person who did support for this archive. */
     const char *url;         /**< URL related to this archive */
+    int supportsSymlinks;    /**< non-zero if archive offers symbolic links. */
 } PHYSFS_ArchiveInfo;
 
 
@@ -3384,13 +3385,7 @@ typedef struct PHYSFS_Archiver
      * This is used to identify your archive, and is returned in
      *  PHYSFS_supportedArchiveTypes().
      */
-// !! FIXME: should this be const?
-    const PHYSFS_ArchiveInfo info;
-
-    /**
-     * !!! FIXME: document me.
-     */    
-    int supportsSymlinks;
+    PHYSFS_ArchiveInfo info;
 
 // !!! FIXME: documentation: \brief?
     /**

+ 2 - 0
test/test_physfs.c

@@ -67,6 +67,8 @@ static void output_archivers(void)
             printf(" * %s: %s\n    Written by %s.\n    %s\n",
                     (*i)->extension, (*i)->description,
                     (*i)->author, (*i)->url);
+            printf("    %s symbolic links.\n",
+                    (*i)->supportsSymlinks ? "Supports" : "Does not support");
         } /* for */
     } /* else */