Skip to content
Permalink
Browse files
Cleaned out "exists" nonsense in openRead() API.
  • Loading branch information
icculus committed Nov 30, 2012
1 parent 697c31e commit 36b542ee7f6bd71805125e4957c61e29c3e02aec
Showing with 11 additions and 24 deletions.
  1. +1 −2 src/archiver_dir.c
  2. +1 −2 src/archiver_iso9660.c
  3. +1 −3 src/archiver_lzma.c
  4. +2 −3 src/archiver_unpacked.c
  5. +2 −4 src/archiver_zip.c
  6. +2 −3 src/physfs.c
  7. +1 −6 src/physfs.h
  8. +1 −1 src/physfs_internal.h
@@ -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 */

@@ -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;
@@ -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);

@@ -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);

@@ -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));
@@ -2452,20 +2452,19 @@ PHYSFS_File *PHYSFS_openRead(const char *_fname)

if (sanitizePlatformIndependentPath(_fname, fname))
{
int fileExists = 0;
DirHandle *i = NULL;
PHYSFS_Io *io = NULL;

__PHYSFS_platformGrabMutex(stateLock);

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 */
@@ -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.
@@ -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);

0 comments on commit 36b542e

Please sign in to comment.