src/archiver_dir.c
changeset 1113 2136d64bd1ad
parent 1111 20d7c2d95a98
child 1118 2e09fc635fdd
equal deleted inserted replaced
1112:12e187aa051c 1113:2136d64bd1ad
    61     BAIL_IF_MACRO(!__PHYSFS_platformClose(opaque), NULL, 0);
    61     BAIL_IF_MACRO(!__PHYSFS_platformClose(opaque), NULL, 0);
    62     return 1;
    62     return 1;
    63 } /* DIR_fileClose */
    63 } /* DIR_fileClose */
    64 
    64 
    65 
    65 
    66 static int DIR_isArchive(const char *filename, int forWriting)
       
    67 {
       
    68     /* directories ARE archives in this driver... */
       
    69     return __PHYSFS_platformIsDirectory(filename);
       
    70 } /* DIR_isArchive */
       
    71 
       
    72 
       
    73 static void *DIR_openArchive(const char *name, int forWriting)
    66 static void *DIR_openArchive(const char *name, int forWriting)
    74 {
    67 {
    75     const char *dirsep = PHYSFS_getDirSeparator();
    68     const char *dirsep = PHYSFS_getDirSeparator();
    76     char *retval = NULL;
    69     char *retval = NULL;
    77     size_t namelen = strlen(name);
    70     size_t namelen = strlen(name);
    78     size_t seplen = strlen(dirsep);
    71     size_t seplen = strlen(dirsep);
    79 
    72 
    80     /* !!! FIXME: when is this not called right before openArchive? */
    73     BAIL_IF_MACRO(!__PHYSFS_platformIsDirectory(name), ERR_NOT_AN_ARCHIVE, NULL);
    81     BAIL_IF_MACRO(!DIR_isArchive(name, forWriting),
       
    82                     ERR_UNSUPPORTED_ARCHIVE, 0);
       
    83 
    74 
    84     retval = allocator.Malloc(namelen + seplen + 1);
    75     retval = allocator.Malloc(namelen + seplen + 1);
    85     BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
    76     BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
    86 
    77 
    87         /* make sure there's a dir separator at the end of the string */
    78         /* make sure there's a dir separator at the end of the string */
   244 
   235 
   245 
   236 
   246 const PHYSFS_Archiver __PHYSFS_Archiver_DIR =
   237 const PHYSFS_Archiver __PHYSFS_Archiver_DIR =
   247 {
   238 {
   248     &__PHYSFS_ArchiveInfo_DIR,
   239     &__PHYSFS_ArchiveInfo_DIR,
   249     DIR_isArchive,          /* isArchive() method      */
       
   250     DIR_openArchive,        /* openArchive() method    */
   240     DIR_openArchive,        /* openArchive() method    */
   251     DIR_enumerateFiles,     /* enumerateFiles() method */
   241     DIR_enumerateFiles,     /* enumerateFiles() method */
   252     DIR_exists,             /* exists() method         */
   242     DIR_exists,             /* exists() method         */
   253     DIR_isDirectory,        /* isDirectory() method    */
   243     DIR_isDirectory,        /* isDirectory() method    */
   254     DIR_isSymLink,          /* isSymLink() method      */
   244     DIR_isSymLink,          /* isSymLink() method      */