src/archiver_wad.c
changeset 1054 57f4af811ffb
parent 1053 a277a93ac1aa
child 1098 4e86cec1143f
equal deleted inserted replaced
1053:a277a93ac1aa 1054:57f4af811ffb
   359         } /* for */
   359         } /* for */
   360     } /* else */
   360     } /* else */
   361 } /* WAD_enumerateFiles */
   361 } /* WAD_enumerateFiles */
   362 
   362 
   363 
   363 
   364 static WADentry *wad_find_entry(WADinfo *info, const char *name)
   364 static WADentry *wad_find_entry(const WADinfo *info, const char *name)
   365 {
   365 {
   366     WADentry *a = info->entries;
   366     WADentry *a = info->entries;
   367     PHYSFS_sint32 lo = 0;
   367     PHYSFS_sint32 lo = 0;
   368     PHYSFS_sint32 hi = (PHYSFS_sint32) (info->entryCount - 1);
   368     PHYSFS_sint32 hi = (PHYSFS_sint32) (info->entryCount - 1);
   369     PHYSFS_sint32 middle;
   369     PHYSFS_sint32 middle;
   490 
   490 
   491 static int WAD_mkdir(dvoid *opaque, const char *name)
   491 static int WAD_mkdir(dvoid *opaque, const char *name)
   492 {
   492 {
   493     BAIL_MACRO(ERR_NOT_SUPPORTED, 0);
   493     BAIL_MACRO(ERR_NOT_SUPPORTED, 0);
   494 } /* WAD_mkdir */
   494 } /* WAD_mkdir */
       
   495 
       
   496 
       
   497 static int WAD_stat(fvoid *opaque, const char *filename, int *exists,
       
   498                     PHYSFS_Stat *stat)
       
   499 {
       
   500     const WADinfo *info = (const WADinfo *) opaque;
       
   501     const WADentry *entry = wad_find_entry(info, filename);
       
   502 
       
   503     *exists = (entry != 0);
       
   504     if (!entry)
       
   505         return 0;
       
   506 
       
   507     stat->filesize = entry->size;
       
   508     stat->filetype = PHYSFS_FILETYPE_REGULAR;
       
   509     stat->accesstime = 0;
       
   510     stat->modtime = ((WADinfo *) opaque)->last_mod_time;
       
   511     stat->createtime = ((WADinfo *) opaque)->last_mod_time;
       
   512     stat->readonly = 1; /* WADs are always readonly */
       
   513 
       
   514     return 0;
       
   515 } /* WAD_stat */
   495 
   516 
   496 
   517 
   497 const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_WAD =
   518 const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_WAD =
   498 {
   519 {
   499     "WAD",
   520     "WAD",
   523     WAD_write,              /* write() method          */
   544     WAD_write,              /* write() method          */
   524     WAD_eof,                /* eof() method            */
   545     WAD_eof,                /* eof() method            */
   525     WAD_tell,               /* tell() method           */
   546     WAD_tell,               /* tell() method           */
   526     WAD_seek,               /* seek() method           */
   547     WAD_seek,               /* seek() method           */
   527     WAD_fileLength,         /* fileLength() method     */
   548     WAD_fileLength,         /* fileLength() method     */
   528     WAD_fileClose           /* fileClose() method      */
   549     WAD_fileClose,          /* fileClose() method      */
       
   550     WAD_stat                /* stat() method           */
   529 };
   551 };
   530 
   552 
   531 #endif  /* defined PHYSFS_SUPPORTS_WAD */
   553 #endif  /* defined PHYSFS_SUPPORTS_WAD */
   532 
   554 
   533 /* end of wad.c ... */
   555 /* end of wad.c ... */