From 36b542ee7f6bd71805125e4957c61e29c3e02aec Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Fri, 30 Nov 2012 13:00:08 -0500 Subject: [PATCH] Cleaned out "exists" nonsense in openRead() API. --- src/archiver_dir.c | 3 +-- src/archiver_iso9660.c | 3 +-- src/archiver_lzma.c | 4 +--- src/archiver_unpacked.c | 5 ++--- src/archiver_zip.c | 6 ++---- src/physfs.c | 5 ++--- src/physfs.h | 7 +------ src/physfs_internal.h | 2 +- 8 files changed, 11 insertions(+), 24 deletions(-) diff --git a/src/archiver_dir.c b/src/archiver_dir.c index c543815f..1665aec0 100644 --- a/src/archiver_dir.c +++ b/src/archiver_dir.c @@ -103,9 +103,8 @@ static PHYSFS_Io *doOpen(void *opaque, const char *name, const int mode) } /* doOpen */ -static PHYSFS_Io *DIR_openRead(void *opaque, const char *filename, int *exists) +static PHYSFS_Io *DIR_openRead(void *opaque, const char *filename) { -// !!! FIXME: exists return doOpen(opaque, filename, 'r'); } /* DIR_openRead */ diff --git a/src/archiver_iso9660.c b/src/archiver_iso9660.c index 3dc01f6c..c27fd912 100644 --- a/src/archiver_iso9660.c +++ b/src/archiver_iso9660.c @@ -764,8 +764,7 @@ static int iso_file_open_foreign(ISO9660Handle *handle, } /* iso_file_open_foreign */ -static PHYSFS_Io *ISO9660_openRead(void *opaque, const char *filename, - int *exists) +static PHYSFS_Io *ISO9660_openRead(void *opaque, const char *filename) { PHYSFS_Io *retval = NULL; ISO9660Handle *handle = (ISO9660Handle*) opaque; diff --git a/src/archiver_lzma.c b/src/archiver_lzma.c index 9d9534a3..8f0f6995 100644 --- a/src/archiver_lzma.c +++ b/src/archiver_lzma.c @@ -575,14 +575,12 @@ static void LZMA_enumerateFiles(void *opaque, const char *dname, } /* LZMA_enumerateFiles */ -static PHYSFS_Io *LZMA_openRead(void *opaque, const char *name, - int *fileExists) +static PHYSFS_Io *LZMA_openRead(void *opaque, const char *name) { LZMAarchive *archive = (LZMAarchive *) opaque; LZMAfile *file = lzma_find_file(archive, name); PHYSFS_Io *io = NULL; - *fileExists = (file != NULL); BAIL_IF_MACRO(file == NULL, PHYSFS_ERR_NOT_FOUND, NULL); BAIL_IF_MACRO(file->folder == NULL, PHYSFS_ERR_NOT_A_FILE, NULL); diff --git a/src/archiver_unpacked.c b/src/archiver_unpacked.c index b809b427..bb0dab6e 100644 --- a/src/archiver_unpacked.c +++ b/src/archiver_unpacked.c @@ -344,15 +344,14 @@ static UNPKentry *findEntry(const UNPKinfo *info, const char *path, int *isDir) } /* findEntry */ -PHYSFS_Io *UNPK_openRead(void *opaque, const char *fnm, int *fileExists) +PHYSFS_Io *UNPK_openRead(void *opaque, const char *name) { PHYSFS_Io *retval = NULL; UNPKinfo *info = (UNPKinfo *) opaque; UNPKfileinfo *finfo = NULL; int isdir = 0; - UNPKentry *entry = findEntry(info, fnm, &isdir); + UNPKentry *entry = findEntry(info, name, &isdir); - *fileExists = (entry != NULL); GOTO_IF_MACRO(isdir, PHYSFS_ERR_NOT_A_FILE, UNPK_openRead_failed); GOTO_IF_MACRO(!entry, ERRPASS, UNPK_openRead_failed); diff --git a/src/archiver_zip.c b/src/archiver_zip.c index 7302323c..d4c0854c 100644 --- a/src/archiver_zip.c +++ b/src/archiver_zip.c @@ -1557,15 +1557,13 @@ static PHYSFS_Io *zip_get_io(PHYSFS_Io *io, ZIPinfo *inf, ZIPentry *entry) } /* zip_get_io */ -static PHYSFS_Io *ZIP_openRead(void *opaque, const char *fnm, - int *fileExists) +static PHYSFS_Io *ZIP_openRead(void *opaque, const char *filename) { PHYSFS_Io *retval = NULL; ZIPinfo *info = (ZIPinfo *) opaque; - ZIPentry *entry = zip_find_entry(info, fnm, NULL); + ZIPentry *entry = zip_find_entry(info, filename, NULL); ZIPfileinfo *finfo = NULL; - *fileExists = (entry != NULL); BAIL_IF_MACRO(!entry, ERRPASS, NULL); retval = (PHYSFS_Io *) allocator.Malloc(sizeof (PHYSFS_Io)); diff --git a/src/physfs.c b/src/physfs.c index 26d352ec..624cbbf6 100644 --- a/src/physfs.c +++ b/src/physfs.c @@ -2452,7 +2452,6 @@ PHYSFS_File *PHYSFS_openRead(const char *_fname) if (sanitizePlatformIndependentPath(_fname, fname)) { - int fileExists = 0; DirHandle *i = NULL; PHYSFS_Io *io = NULL; @@ -2460,12 +2459,12 @@ PHYSFS_File *PHYSFS_openRead(const char *_fname) GOTO_IF_MACRO(!searchPath, PHYSFS_ERR_NOT_FOUND, openReadEnd); - for (i = searchPath; (i != NULL) && (!fileExists); i = i->next) + for (i = searchPath; i != NULL; i = i->next) { char *arcfname = fname; if (verifyPath(i, &arcfname, 0)) { - io = i->funcs->openRead(i->opaque, arcfname, &fileExists); + io = i->funcs->openRead(i->opaque, arcfname); if (io) break; } /* if */ diff --git a/src/physfs.h b/src/physfs.h index 7084dfe8..4d938bf9 100644 --- a/src/physfs.h +++ b/src/physfs.h @@ -3426,13 +3426,8 @@ typedef struct PHYSFS_Archiver * Returns NULL on failure, and calls PHYSFS_setErrorCode(). * Returns non-NULL on success. The pointer returned will be * passed as the "opaque" parameter for later file calls. - * - * Regardless of success or failure, please set *exists to - * non-zero if the file existed (even if it's a broken symlink!), - * zero if it did not. */ -// !!! FIXME: get rid of the exists nonsense, check error code instead. - PHYSFS_Io *(*openRead)(void *opaque, const char *fnm, int *exists); + PHYSFS_Io *(*openRead)(void *opaque, const char *fnm); /** * Open file for writing. diff --git a/src/physfs_internal.h b/src/physfs_internal.h index 46a327de..a954bc46 100644 --- a/src/physfs_internal.h +++ b/src/physfs_internal.h @@ -293,7 +293,7 @@ void *UNPK_openArchive(PHYSFS_Io *io,UNPKentry *e,const PHYSFS_uint32 n); void UNPK_enumerateFiles(void *opaque, const char *dname, PHYSFS_EnumFilesCallback cb, const char *origdir, void *callbackdata); -PHYSFS_Io *UNPK_openRead(void *opaque, const char *fnm, int *fileExists); +PHYSFS_Io *UNPK_openRead(void *opaque, const char *name); PHYSFS_Io *UNPK_openWrite(void *opaque, const char *name); PHYSFS_Io *UNPK_openAppend(void *opaque, const char *name); int UNPK_remove(void *opaque, const char *name);