Cleaned out "exists" nonsense in openRead() API.

This commit is contained in:
Ryan C. Gordon 2012-11-30 13:00:08 -05:00
parent 697c31e81b
commit 36b542ee7f
8 changed files with 11 additions and 24 deletions

View File

@ -103,9 +103,8 @@ static PHYSFS_Io *doOpen(void *opaque, const char *name, const int mode)
} /* doOpen */ } /* 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'); return doOpen(opaque, filename, 'r');
} /* DIR_openRead */ } /* DIR_openRead */

View File

@ -764,8 +764,7 @@ closefile:
} /* iso_file_open_foreign */ } /* iso_file_open_foreign */
static PHYSFS_Io *ISO9660_openRead(void *opaque, const char *filename, static PHYSFS_Io *ISO9660_openRead(void *opaque, const char *filename)
int *exists)
{ {
PHYSFS_Io *retval = NULL; PHYSFS_Io *retval = NULL;
ISO9660Handle *handle = (ISO9660Handle*) opaque; ISO9660Handle *handle = (ISO9660Handle*) opaque;

View File

@ -575,14 +575,12 @@ static void LZMA_enumerateFiles(void *opaque, const char *dname,
} /* LZMA_enumerateFiles */ } /* LZMA_enumerateFiles */
static PHYSFS_Io *LZMA_openRead(void *opaque, const char *name, static PHYSFS_Io *LZMA_openRead(void *opaque, const char *name)
int *fileExists)
{ {
LZMAarchive *archive = (LZMAarchive *) opaque; LZMAarchive *archive = (LZMAarchive *) opaque;
LZMAfile *file = lzma_find_file(archive, name); LZMAfile *file = lzma_find_file(archive, name);
PHYSFS_Io *io = NULL; PHYSFS_Io *io = NULL;
*fileExists = (file != NULL);
BAIL_IF_MACRO(file == NULL, PHYSFS_ERR_NOT_FOUND, NULL); BAIL_IF_MACRO(file == NULL, PHYSFS_ERR_NOT_FOUND, NULL);
BAIL_IF_MACRO(file->folder == NULL, PHYSFS_ERR_NOT_A_FILE, NULL); BAIL_IF_MACRO(file->folder == NULL, PHYSFS_ERR_NOT_A_FILE, NULL);

View File

@ -344,15 +344,14 @@ static UNPKentry *findEntry(const UNPKinfo *info, const char *path, int *isDir)
} /* findEntry */ } /* 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; PHYSFS_Io *retval = NULL;
UNPKinfo *info = (UNPKinfo *) opaque; UNPKinfo *info = (UNPKinfo *) opaque;
UNPKfileinfo *finfo = NULL; UNPKfileinfo *finfo = NULL;
int isdir = 0; 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(isdir, PHYSFS_ERR_NOT_A_FILE, UNPK_openRead_failed);
GOTO_IF_MACRO(!entry, ERRPASS, UNPK_openRead_failed); GOTO_IF_MACRO(!entry, ERRPASS, UNPK_openRead_failed);

View File

@ -1557,15 +1557,13 @@ static PHYSFS_Io *zip_get_io(PHYSFS_Io *io, ZIPinfo *inf, ZIPentry *entry)
} /* zip_get_io */ } /* zip_get_io */
static PHYSFS_Io *ZIP_openRead(void *opaque, const char *fnm, static PHYSFS_Io *ZIP_openRead(void *opaque, const char *filename)
int *fileExists)
{ {
PHYSFS_Io *retval = NULL; PHYSFS_Io *retval = NULL;
ZIPinfo *info = (ZIPinfo *) opaque; ZIPinfo *info = (ZIPinfo *) opaque;
ZIPentry *entry = zip_find_entry(info, fnm, NULL); ZIPentry *entry = zip_find_entry(info, filename, NULL);
ZIPfileinfo *finfo = NULL; ZIPfileinfo *finfo = NULL;
*fileExists = (entry != NULL);
BAIL_IF_MACRO(!entry, ERRPASS, NULL); BAIL_IF_MACRO(!entry, ERRPASS, NULL);
retval = (PHYSFS_Io *) allocator.Malloc(sizeof (PHYSFS_Io)); retval = (PHYSFS_Io *) allocator.Malloc(sizeof (PHYSFS_Io));

View File

@ -2452,7 +2452,6 @@ PHYSFS_File *PHYSFS_openRead(const char *_fname)
if (sanitizePlatformIndependentPath(_fname, fname)) if (sanitizePlatformIndependentPath(_fname, fname))
{ {
int fileExists = 0;
DirHandle *i = NULL; DirHandle *i = NULL;
PHYSFS_Io *io = 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); 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; char *arcfname = fname;
if (verifyPath(i, &arcfname, 0)) if (verifyPath(i, &arcfname, 0))
{ {
io = i->funcs->openRead(i->opaque, arcfname, &fileExists); io = i->funcs->openRead(i->opaque, arcfname);
if (io) if (io)
break; break;
} /* if */ } /* if */

View File

@ -3426,13 +3426,8 @@ typedef struct PHYSFS_Archiver
* Returns NULL on failure, and calls PHYSFS_setErrorCode(). * Returns NULL on failure, and calls PHYSFS_setErrorCode().
* Returns non-NULL on success. The pointer returned will be * Returns non-NULL on success. The pointer returned will be
* passed as the "opaque" parameter for later file calls. * 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);
PHYSFS_Io *(*openRead)(void *opaque, const char *fnm, int *exists);
/** /**
* Open file for writing. * Open file for writing.

View File

@ -293,7 +293,7 @@ void *UNPK_openArchive(PHYSFS_Io *io,UNPKentry *e,const PHYSFS_uint32 n);
void UNPK_enumerateFiles(void *opaque, const char *dname, void UNPK_enumerateFiles(void *opaque, const char *dname,
PHYSFS_EnumFilesCallback cb, PHYSFS_EnumFilesCallback cb,
const char *origdir, void *callbackdata); 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_openWrite(void *opaque, const char *name);
PHYSFS_Io *UNPK_openAppend(void *opaque, const char *name); PHYSFS_Io *UNPK_openAppend(void *opaque, const char *name);
int UNPK_remove(void *opaque, const char *name); int UNPK_remove(void *opaque, const char *name);