Removed PHYSFS_Archiver's isArchive() method.
It was redundant with openArchive().
This commit is contained in:
parent
c92f3035f9
commit
fc680aa468
|
@ -63,13 +63,6 @@ static int DIR_fileClose(fvoid *opaque)
|
|||
} /* DIR_fileClose */
|
||||
|
||||
|
||||
static int DIR_isArchive(const char *filename, int forWriting)
|
||||
{
|
||||
/* directories ARE archives in this driver... */
|
||||
return __PHYSFS_platformIsDirectory(filename);
|
||||
} /* DIR_isArchive */
|
||||
|
||||
|
||||
static void *DIR_openArchive(const char *name, int forWriting)
|
||||
{
|
||||
const char *dirsep = PHYSFS_getDirSeparator();
|
||||
|
@ -77,9 +70,7 @@ static void *DIR_openArchive(const char *name, int forWriting)
|
|||
size_t namelen = strlen(name);
|
||||
size_t seplen = strlen(dirsep);
|
||||
|
||||
/* !!! FIXME: when is this not called right before openArchive? */
|
||||
BAIL_IF_MACRO(!DIR_isArchive(name, forWriting),
|
||||
ERR_UNSUPPORTED_ARCHIVE, 0);
|
||||
BAIL_IF_MACRO(!__PHYSFS_platformIsDirectory(name), ERR_NOT_AN_ARCHIVE, NULL);
|
||||
|
||||
retval = allocator.Malloc(namelen + seplen + 1);
|
||||
BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
|
||||
|
@ -246,7 +237,6 @@ const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_DIR =
|
|||
const PHYSFS_Archiver __PHYSFS_Archiver_DIR =
|
||||
{
|
||||
&__PHYSFS_ArchiveInfo_DIR,
|
||||
DIR_isArchive, /* isArchive() method */
|
||||
DIR_openArchive, /* openArchive() method */
|
||||
DIR_enumerateFiles, /* enumerateFiles() method */
|
||||
DIR_exists, /* exists() method */
|
||||
|
|
|
@ -179,19 +179,6 @@ openGrp_failed:
|
|||
} /* grp_open */
|
||||
|
||||
|
||||
static int GRP_isArchive(const char *filename, int forWriting)
|
||||
{
|
||||
void *fh;
|
||||
PHYSFS_uint32 fileCount;
|
||||
int retval = grp_open(filename, forWriting, &fh, &fileCount);
|
||||
|
||||
if (fh != NULL)
|
||||
__PHYSFS_platformClose(fh);
|
||||
|
||||
return retval;
|
||||
} /* GRP_isArchive */
|
||||
|
||||
|
||||
static int grp_entry_cmp(void *_a, PHYSFS_uint32 one, PHYSFS_uint32 two)
|
||||
{
|
||||
if (one != two)
|
||||
|
@ -451,7 +438,6 @@ const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_GRP =
|
|||
const PHYSFS_Archiver __PHYSFS_Archiver_GRP =
|
||||
{
|
||||
&__PHYSFS_ArchiveInfo_GRP,
|
||||
GRP_isArchive, /* isArchive() method */
|
||||
GRP_openArchive, /* openArchive() method */
|
||||
GRP_enumerateFiles, /* enumerateFiles() method */
|
||||
GRP_exists, /* exists() method */
|
||||
|
|
|
@ -216,19 +216,6 @@ openHog_failed:
|
|||
} /* hog_open */
|
||||
|
||||
|
||||
static int HOG_isArchive(const char *filename, int forWriting)
|
||||
{
|
||||
void *fh;
|
||||
PHYSFS_uint32 fileCount;
|
||||
int retval = hog_open(filename, forWriting, &fh, &fileCount);
|
||||
|
||||
if (fh != NULL)
|
||||
__PHYSFS_platformClose(fh);
|
||||
|
||||
return retval;
|
||||
} /* HOG_isArchive */
|
||||
|
||||
|
||||
static int hog_entry_cmp(void *_a, PHYSFS_uint32 one, PHYSFS_uint32 two)
|
||||
{
|
||||
if (one != two)
|
||||
|
@ -304,7 +291,7 @@ static void *HOG_openArchive(const char *name, int forWriting)
|
|||
PHYSFS_sint64 modtime = __PHYSFS_platformGetLastModTime(name);
|
||||
HOGinfo *info = (HOGinfo *) allocator.Malloc(sizeof (HOGinfo));
|
||||
|
||||
BAIL_IF_MACRO(info == NULL, ERR_OUT_OF_MEMORY, 0);
|
||||
BAIL_IF_MACRO(info == NULL, ERR_OUT_OF_MEMORY, NULL);
|
||||
memset(info, '\0', sizeof (HOGinfo));
|
||||
info->filename = (char *) allocator.Malloc(strlen(name) + 1);
|
||||
GOTO_IF_MACRO(!info->filename, ERR_OUT_OF_MEMORY, HOG_openArchive_failed);
|
||||
|
@ -486,7 +473,6 @@ const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_HOG =
|
|||
const PHYSFS_Archiver __PHYSFS_Archiver_HOG =
|
||||
{
|
||||
&__PHYSFS_ArchiveInfo_HOG,
|
||||
HOG_isArchive, /* isArchive() method */
|
||||
HOG_openArchive, /* openArchive() method */
|
||||
HOG_enumerateFiles, /* enumerateFiles() method */
|
||||
HOG_exists, /* exists() method */
|
||||
|
|
|
@ -483,13 +483,12 @@ static int iso_read_ext_attributes(ISO9660Handle *handle, int block,
|
|||
* Archive management functions
|
||||
******************************************************************************/
|
||||
|
||||
static int ISO9660_isArchive(const char *filename, int forWriting)
|
||||
/* !!! FIXME: don't open/close file here, merge with openArchive(). */
|
||||
static int isIso(const char *filename)
|
||||
{
|
||||
char magicnumber[6] = {0,0,0,0,0,0};
|
||||
void *in;
|
||||
|
||||
BAIL_IF_MACRO(forWriting, ERR_ARC_IS_READ_ONLY, 0);
|
||||
|
||||
in = __PHYSFS_platformOpenRead(filename);
|
||||
BAIL_IF_MACRO(in == NULL, NULL, 0);
|
||||
|
||||
|
@ -510,7 +509,7 @@ static int ISO9660_isArchive(const char *filename, int forWriting)
|
|||
__PHYSFS_platformClose(in);
|
||||
|
||||
return (strcmp(magicnumber, "CD001") == 0);
|
||||
} /* ISO9660_isArchive */
|
||||
} /* isIso */
|
||||
|
||||
|
||||
static void *ISO9660_openArchive(const char *filename, int forWriting)
|
||||
|
@ -518,7 +517,9 @@ static void *ISO9660_openArchive(const char *filename, int forWriting)
|
|||
ISO9660Handle *handle;
|
||||
int founddescriptor = 0;
|
||||
int foundjoliet = 0;
|
||||
BAIL_IF_MACRO(forWriting, ERR_ARC_IS_READ_ONLY, NULL);
|
||||
|
||||
BAIL_IF_MACRO(forWriting, ERR_ARC_IS_READ_ONLY, 0);
|
||||
BAIL_IF_MACRO(!isIso(filename), ERR_UNSUPPORTED_ARCHIVE, NULL);
|
||||
|
||||
handle = allocator.Malloc(sizeof(ISO9660Handle));
|
||||
GOTO_IF_MACRO(!handle, ERR_OUT_OF_MEMORY, errorcleanup);
|
||||
|
@ -985,7 +986,6 @@ const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_ISO9660 =
|
|||
const PHYSFS_Archiver __PHYSFS_Archiver_ISO9660 =
|
||||
{
|
||||
&__PHYSFS_ArchiveInfo_ISO9660,
|
||||
ISO9660_isArchive, /* isArchive() method */
|
||||
ISO9660_openArchive, /* openArchive() method */
|
||||
ISO9660_enumerateFiles, /* enumerateFiles() method */
|
||||
ISO9660_exists, /* exists() method */
|
||||
|
|
|
@ -430,13 +430,12 @@ static int LZMA_fileClose(fvoid *opaque)
|
|||
} /* LZMA_fileClose */
|
||||
|
||||
|
||||
static int LZMA_isArchive(const char *filename, int forWriting)
|
||||
/* !!! FIXME: don't open/close file here, merge with openArchive(). */
|
||||
static int isLzma(const char *filename)
|
||||
{
|
||||
PHYSFS_uint8 sig[k7zSignatureSize];
|
||||
void *in;
|
||||
|
||||
BAIL_IF_MACRO(forWriting, ERR_ARC_IS_READ_ONLY, 0);
|
||||
|
||||
in = __PHYSFS_platformOpenRead(filename);
|
||||
BAIL_IF_MACRO(in == NULL, NULL, 0);
|
||||
|
||||
|
@ -451,7 +450,7 @@ static int LZMA_isArchive(const char *filename, int forWriting)
|
|||
|
||||
/* Test whether sig is the 7z signature */
|
||||
return TestSignatureCandidate(sig);
|
||||
} /* LZMA_isArchive */
|
||||
} /* isLzma */
|
||||
|
||||
|
||||
static void *LZMA_openArchive(const char *name, int forWriting)
|
||||
|
@ -460,7 +459,7 @@ static void *LZMA_openArchive(const char *name, int forWriting)
|
|||
LZMAarchive *archive = NULL;
|
||||
|
||||
BAIL_IF_MACRO(forWriting, ERR_ARC_IS_READ_ONLY, NULL);
|
||||
BAIL_IF_MACRO(!LZMA_isArchive(name,forWriting), ERR_UNSUPPORTED_ARCHIVE, 0);
|
||||
BAIL_IF_MACRO(!isLzma(name), ERR_UNSUPPORTED_ARCHIVE, NULL);
|
||||
|
||||
archive = (LZMAarchive *) allocator.Malloc(sizeof (LZMAarchive));
|
||||
BAIL_IF_MACRO(archive == NULL, ERR_OUT_OF_MEMORY, NULL);
|
||||
|
@ -721,7 +720,6 @@ const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_LZMA =
|
|||
const PHYSFS_Archiver __PHYSFS_Archiver_LZMA =
|
||||
{
|
||||
&__PHYSFS_ArchiveInfo_LZMA,
|
||||
LZMA_isArchive, /* isArchive() method */
|
||||
LZMA_openArchive, /* openArchive() method */
|
||||
LZMA_enumerateFiles, /* enumerateFiles() method */
|
||||
LZMA_exists, /* exists() method */
|
||||
|
|
|
@ -176,19 +176,6 @@ openMvl_failed:
|
|||
} /* mvl_open */
|
||||
|
||||
|
||||
static int MVL_isArchive(const char *filename, int forWriting)
|
||||
{
|
||||
void *fh;
|
||||
PHYSFS_uint32 fileCount;
|
||||
int retval = mvl_open(filename, forWriting, &fh, &fileCount);
|
||||
|
||||
if (fh != NULL)
|
||||
__PHYSFS_platformClose(fh);
|
||||
|
||||
return retval;
|
||||
} /* MVL_isArchive */
|
||||
|
||||
|
||||
static int mvl_entry_cmp(void *_a, PHYSFS_uint32 one, PHYSFS_uint32 two)
|
||||
{
|
||||
if (one != two)
|
||||
|
@ -446,7 +433,6 @@ const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_MVL =
|
|||
const PHYSFS_Archiver __PHYSFS_Archiver_MVL =
|
||||
{
|
||||
&__PHYSFS_ArchiveInfo_MVL,
|
||||
MVL_isArchive, /* isArchive() method */
|
||||
MVL_openArchive, /* openArchive() method */
|
||||
MVL_enumerateFiles, /* enumerateFiles() method */
|
||||
MVL_exists, /* exists() method */
|
||||
|
|
|
@ -204,19 +204,6 @@ openQpak_failed:
|
|||
} /* qpak_open */
|
||||
|
||||
|
||||
static int QPAK_isArchive(const char *filename, int forWriting)
|
||||
{
|
||||
void *fh;
|
||||
PHYSFS_uint32 fileCount;
|
||||
int retval = qpak_open(filename, forWriting, &fh, &fileCount);
|
||||
|
||||
if (fh != NULL)
|
||||
__PHYSFS_platformClose(fh);
|
||||
|
||||
return retval;
|
||||
} /* QPAK_isArchive */
|
||||
|
||||
|
||||
static int qpak_entry_cmp(void *_a, PHYSFS_uint32 one, PHYSFS_uint32 two)
|
||||
{
|
||||
if (one != two)
|
||||
|
@ -607,7 +594,6 @@ const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_QPAK =
|
|||
const PHYSFS_Archiver __PHYSFS_Archiver_QPAK =
|
||||
{
|
||||
&__PHYSFS_ArchiveInfo_QPAK,
|
||||
QPAK_isArchive, /* isArchive() method */
|
||||
QPAK_openArchive, /* openArchive() method */
|
||||
QPAK_enumerateFiles, /* enumerateFiles() method */
|
||||
QPAK_exists, /* exists() method */
|
||||
|
|
|
@ -203,19 +203,6 @@ openWad_failed:
|
|||
} /* wad_open */
|
||||
|
||||
|
||||
static int WAD_isArchive(const char *filename, int forWriting)
|
||||
{
|
||||
void *fh;
|
||||
PHYSFS_uint32 fileCount,offset;
|
||||
int retval = wad_open(filename, forWriting, &fh, &fileCount,&offset);
|
||||
|
||||
if (fh != NULL)
|
||||
__PHYSFS_platformClose(fh);
|
||||
|
||||
return retval;
|
||||
} /* WAD_isArchive */
|
||||
|
||||
|
||||
static int wad_entry_cmp(void *_a, PHYSFS_uint32 one, PHYSFS_uint32 two)
|
||||
{
|
||||
if (one != two)
|
||||
|
@ -505,7 +492,6 @@ const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_WAD =
|
|||
const PHYSFS_Archiver __PHYSFS_Archiver_WAD =
|
||||
{
|
||||
&__PHYSFS_ArchiveInfo_WAD,
|
||||
WAD_isArchive, /* isArchive() method */
|
||||
WAD_openArchive, /* openArchive() method */
|
||||
WAD_enumerateFiles, /* enumerateFiles() method */
|
||||
WAD_exists, /* exists() method */
|
||||
|
|
|
@ -450,7 +450,8 @@ static PHYSFS_sint64 zip_find_end_of_central_dir(void *in, PHYSFS_sint64 *len)
|
|||
} /* zip_find_end_of_central_dir */
|
||||
|
||||
|
||||
static int ZIP_isArchive(const char *filename, int forWriting)
|
||||
/* !!! FIXME: don't open/close file here, merge with openArchive(). */
|
||||
static int isZip(const char *filename)
|
||||
{
|
||||
PHYSFS_uint32 sig;
|
||||
int retval = 0;
|
||||
|
@ -479,7 +480,7 @@ static int ZIP_isArchive(const char *filename, int forWriting)
|
|||
|
||||
__PHYSFS_platformClose(in);
|
||||
return retval;
|
||||
} /* ZIP_isArchive */
|
||||
} /* isZip */
|
||||
|
||||
|
||||
static void zip_free_entries(ZIPentry *entries, PHYSFS_uint32 max)
|
||||
|
@ -1084,6 +1085,7 @@ static void *ZIP_openArchive(const char *name, int forWriting)
|
|||
PHYSFS_uint32 cent_dir_ofs;
|
||||
|
||||
BAIL_IF_MACRO(forWriting, ERR_ARC_IS_READ_ONLY, NULL);
|
||||
BAIL_IF_MACRO(!isZip(name), NULL, NULL);
|
||||
|
||||
if ((in = __PHYSFS_platformOpenRead(name)) == NULL)
|
||||
goto zip_openarchive_failed;
|
||||
|
@ -1432,7 +1434,6 @@ const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_ZIP =
|
|||
const PHYSFS_Archiver __PHYSFS_Archiver_ZIP =
|
||||
{
|
||||
&__PHYSFS_ArchiveInfo_ZIP,
|
||||
ZIP_isArchive, /* isArchive() method */
|
||||
ZIP_openArchive, /* openArchive() method */
|
||||
ZIP_enumerateFiles, /* enumerateFiles() method */
|
||||
ZIP_exists, /* exists() method */
|
||||
|
|
|
@ -103,7 +103,6 @@ static const PHYSFS_ArchiveInfo *supported_types[] =
|
|||
|
||||
static const PHYSFS_Archiver *archivers[] =
|
||||
{
|
||||
&__PHYSFS_Archiver_DIR,
|
||||
#if (defined PHYSFS_SUPPORTS_ZIP)
|
||||
&__PHYSFS_Archiver_ZIP,
|
||||
#endif
|
||||
|
@ -401,8 +400,6 @@ static DirHandle *tryOpenDir(const PHYSFS_Archiver *funcs,
|
|||
const char *d, int forWriting)
|
||||
{
|
||||
DirHandle *retval = NULL;
|
||||
if (funcs->isArchive(d, forWriting))
|
||||
{
|
||||
void *opaque = funcs->openArchive(d, forWriting);
|
||||
if (opaque != NULL)
|
||||
{
|
||||
|
@ -417,7 +414,6 @@ static DirHandle *tryOpenDir(const PHYSFS_Archiver *funcs,
|
|||
retval->opaque = opaque;
|
||||
} /* else */
|
||||
} /* if */
|
||||
} /* if */
|
||||
|
||||
return retval;
|
||||
} /* tryOpenDir */
|
||||
|
@ -431,6 +427,11 @@ static DirHandle *openDirectory(const char *d, int forWriting)
|
|||
|
||||
BAIL_IF_MACRO(!__PHYSFS_platformExists(d), ERR_NO_SUCH_FILE, NULL);
|
||||
|
||||
/* DIR gets first shot (unlike the rest, it doesn't deal with files). */
|
||||
retval = tryOpenDir(&__PHYSFS_Archiver_DIR, d, forWriting);
|
||||
if (retval != NULL)
|
||||
return retval;
|
||||
|
||||
ext = find_filename_extension(d);
|
||||
if (ext != NULL)
|
||||
{
|
||||
|
|
|
@ -740,16 +740,6 @@ typedef struct
|
|||
* continue to call other methods based on that.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Returns non-zero if (filename) is a valid archive that this
|
||||
* driver can handle. This filename is in platform-dependent
|
||||
* notation. forWriting is non-zero if this is to be used for
|
||||
* the write directory, and zero if this is to be used for an
|
||||
* element of the search path.
|
||||
*/
|
||||
int (*isArchive)(const char *filename, int forWriting);
|
||||
|
||||
/*
|
||||
* Open a dirhandle for dir/archive (name).
|
||||
* This filename is in platform-dependent notation.
|
||||
|
|
Loading…
Reference in New Issue