Cleaned out "exists" nonsense in openRead() API.
authorRyan C. Gordon <icculus@icculus.org>
Fri, 30 Nov 2012 13:00:08 -0500
changeset 1329 919f885155d8
parent 1328 a5314f07614a
child 1330 ce6b4a66b3eb
Cleaned out "exists" nonsense in openRead() API.
src/archiver_dir.c
src/archiver_iso9660.c
src/archiver_lzma.c
src/archiver_unpacked.c
src/archiver_zip.c
src/physfs.c
src/physfs.h
src/physfs_internal.h
--- a/src/archiver_dir.c	Fri Nov 30 12:49:25 2012 -0500
+++ b/src/archiver_dir.c	Fri Nov 30 13:00:08 2012 -0500
@@ -103,9 +103,8 @@
 } /* 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 */
 
--- a/src/archiver_iso9660.c	Fri Nov 30 12:49:25 2012 -0500
+++ b/src/archiver_iso9660.c	Fri Nov 30 13:00:08 2012 -0500
@@ -764,8 +764,7 @@
 } /* 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;
--- a/src/archiver_lzma.c	Fri Nov 30 12:49:25 2012 -0500
+++ b/src/archiver_lzma.c	Fri Nov 30 13:00:08 2012 -0500
@@ -575,14 +575,12 @@
 } /* 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);
 
--- a/src/archiver_unpacked.c	Fri Nov 30 12:49:25 2012 -0500
+++ b/src/archiver_unpacked.c	Fri Nov 30 13:00:08 2012 -0500
@@ -344,15 +344,14 @@
 } /* 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);
 
--- a/src/archiver_zip.c	Fri Nov 30 12:49:25 2012 -0500
+++ b/src/archiver_zip.c	Fri Nov 30 13:00:08 2012 -0500
@@ -1557,15 +1557,13 @@
 } /* 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));
--- a/src/physfs.c	Fri Nov 30 12:49:25 2012 -0500
+++ b/src/physfs.c	Fri Nov 30 13:00:08 2012 -0500
@@ -2452,7 +2452,6 @@
 
     if (sanitizePlatformIndependentPath(_fname, fname))
     {
-        int fileExists = 0;
         DirHandle *i = NULL;
         PHYSFS_Io *io = NULL;
 
@@ -2460,12 +2459,12 @@
 
         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 */
--- a/src/physfs.h	Fri Nov 30 12:49:25 2012 -0500
+++ b/src/physfs.h	Fri Nov 30 13:00:08 2012 -0500
@@ -3426,13 +3426,8 @@
      * 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.
--- a/src/physfs_internal.h	Fri Nov 30 12:49:25 2012 -0500
+++ b/src/physfs_internal.h	Fri Nov 30 13:00:08 2012 -0500
@@ -293,7 +293,7 @@
 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);