Procházet zdrojové kódy

PHYSFS_getRealDir() can't report a path for things that aren't real files.

Ryan C. Gordon před 15 roky
rodič
revize
d9e98704f7
2 změnil soubory, kde provedl 12 přidání a 1 odebrání
  1. 7 1
      src/physfs.c
  2. 5 0
      src/physfs.h

+ 7 - 1
src/physfs.c

@@ -1828,15 +1828,21 @@ const char *PHYSFS_getRealDir(const char *_fname)
     {
     {
         DirHandle *i;
         DirHandle *i;
         __PHYSFS_platformGrabMutex(stateLock);
         __PHYSFS_platformGrabMutex(stateLock);
-        for (i = searchPath; ((i != NULL) && (retval == NULL)); i = i->next)
+        for (i = searchPath; i != NULL; i = i->next)
         {
         {
             char *arcfname = fname;
             char *arcfname = fname;
             if (partOfMountPoint(i, arcfname))
             if (partOfMountPoint(i, arcfname))
+            {
                 retval = i->dirName;
                 retval = i->dirName;
+                break;
+            } /* if */
             else if (verifyPath(i, &arcfname, 0))
             else if (verifyPath(i, &arcfname, 0))
             {
             {
                 if (i->funcs->exists(i->opaque, arcfname))
                 if (i->funcs->exists(i->opaque, arcfname))
+                {
                     retval = i->dirName;
                     retval = i->dirName;
+                    break;
+                } /* if */
             } /* if */
             } /* if */
         } /* for */
         } /* for */
         __PHYSFS_platformReleaseMutex(stateLock);
         __PHYSFS_platformReleaseMutex(stateLock);

+ 5 - 0
src/physfs.h

@@ -1020,6 +1020,11 @@ PHYSFS_DECL int PHYSFS_delete(const char *filename);
  *  be associated with the first archive mounted there, even though that
  *  be associated with the first archive mounted there, even though that
  *  directory isn't necessarily contained in a real archive.
  *  directory isn't necessarily contained in a real archive.
  *
  *
+ * \warning This will return NULL if there is no real directory associated
+ *          with (filename). Specifically, PHYSFS_mountIo(),
+ *          PHYSFS_mountMemory(), and PHYSFS_mountHandle() will return NULL
+ *          even if the filename is found in the search path. Plan accordingly.
+ *
  *     \param filename file to look for.
  *     \param filename file to look for.
  *    \return READ ONLY string of element of search path containing the
  *    \return READ ONLY string of element of search path containing the
  *             the file in question. NULL if not found.
  *             the file in question. NULL if not found.