Added PHYSFS_unmount(), deprecated addToSearchPath and removeFromSearchPath.
authorRyan C. Gordon <icculus@icculus.org>
Sun, 22 Aug 2010 03:43:22 -0400
changeset 1110 803e5e8a0ff8
parent 1109 c69df75dbcc3
child 1111 20d7c2d95a98
Added PHYSFS_unmount(), deprecated addToSearchPath and removeFromSearchPath.
extras/physfs-swig.i
src/physfs.c
src/physfs.h
test/test_physfs.c
--- a/extras/physfs-swig.i	Sun Aug 22 03:35:55 2010 -0400
+++ b/extras/physfs-swig.i	Sun Aug 22 03:43:22 2010 -0400
@@ -88,6 +88,7 @@
 %rename(stat) PHYSFS_stat;
 %rename(readBytes) PHYSFS_readBytes;
 %rename(writeBytes) PHYSFS_writeBytes;
+%rename(unmount) PHYSFS_unmount;
 #endif
 
 %include "../src/physfs.h"
--- a/src/physfs.c	Sun Aug 22 03:35:55 2010 -0400
+++ b/src/physfs.c	Sun Aug 22 03:43:22 2010 -0400
@@ -1004,6 +1004,12 @@
 
 int PHYSFS_removeFromSearchPath(const char *oldDir)
 {
+    return PHYSFS_unmount(oldDir);
+} /* PHYSFS_removeFromSearchPath */
+
+
+int PHYSFS_unmount(const char *oldDir)
+{
     DirHandle *i;
     DirHandle *prev = NULL;
     DirHandle *next = NULL;
@@ -1030,7 +1036,7 @@
     } /* for */
 
     BAIL_MACRO_MUTEX(ERR_NOT_IN_SEARCH_PATH, stateLock, 0);
-} /* PHYSFS_removeFromSearchPath */
+} /* PHYSFS_unmount */
 
 
 char **PHYSFS_getSearchPath(void)
@@ -1081,7 +1087,7 @@
     if (str != NULL)
     {
         sprintf(str, "%s%s%s", d, dirsep, i);
-        PHYSFS_addToSearchPath(str, archivesFirst == 0);
+        PHYSFS_mount(str, NULL, archivesFirst == 0);
         __PHYSFS_smallFree(str);
     } /* if */
 } /* setSaneCfgAddPath */
@@ -1133,11 +1139,11 @@
     } /* if */
 
     /* Put write dir first in search path... */
-    PHYSFS_addToSearchPath(str, 0);
+    PHYSFS_mount(str, NULL, 0);
     __PHYSFS_smallFree(str);
 
         /* Put base path on search path... */
-    PHYSFS_addToSearchPath(basedir, 1);
+    PHYSFS_mount(basedir, NULL, 1);
 
         /* handle CD-ROMs... */
     if (includeCdRoms)
@@ -1145,7 +1151,7 @@
         char **cds = PHYSFS_getCdRomDirs();
         char **i;
         for (i = cds; *i != NULL; i++)
-            PHYSFS_addToSearchPath(*i, 1);
+            PHYSFS_mount(*i, NULL, 1);
 
         PHYSFS_freeList(cds);
     } /* if */
--- a/src/physfs.h	Sun Aug 22 03:35:55 2010 -0400
+++ b/src/physfs.h	Sun Aug 22 03:43:22 2010 -0400
@@ -800,8 +800,14 @@
  * \fn int PHYSFS_addToSearchPath(const char *newDir, int appendToPath)
  * \brief Add an archive or directory to the search path.
  *
- * This is a legacy call in PhysicsFS 2.0, equivalent to:
- *     PHYSFS_mount(newDir, NULL, appendToPath);
+ * \deprecated As of PhysicsFS 2.0, use PHYSFS_mount() instead. This
+ *             function just wraps it anyhow.
+ *
+ * This function is equivalent to:
+ *
+ * \code
+ *  PHYSFS_mount(newDir, NULL, appendToPath);
+ * \endcode
  *
  * You must use this and not PHYSFS_mount if binary compatibility with
  *  PhysicsFS 1.0 is important (which it may not be for many people).
@@ -810,27 +816,35 @@
  * \sa PHYSFS_removeFromSearchPath
  * \sa PHYSFS_getSearchPath
  */
-PHYSFS_DECL int PHYSFS_addToSearchPath(const char *newDir, int appendToPath);
-
+PHYSFS_DECL int PHYSFS_addToSearchPath(const char *newDir, int appendToPath)
+                                        PHYSFS_DEPRECATED;
 
 /**
  * \fn int PHYSFS_removeFromSearchPath(const char *oldDir)
  * \brief Remove a directory or archive from the search path.
  *
- * This must be a (case-sensitive) match to a dir or archive already in the
- *  search path, specified in platform-dependent notation.
- *
- * This call will fail (and fail to remove from the path) if the element still
- *  has files open in it.
- *
- *    \param oldDir dir/archive to remove.
- *   \return nonzero on success, zero on failure.
- *            Specifics of the error can be gleaned from PHYSFS_getLastError().
+ * \deprecated As of PhysicsFS 2.1, use PHYSFS_unmount() instead. This
+ *             function just wraps it anyhow. There's no functional difference
+ *             except the vocabulary changed from "adding to the search path"
+ *             to "mounting" when that functionality was extended, and thus
+ *             the preferred way to accomplish this function's work is now
+ *             called "unmounting."
+ *
+ * This function is equivalent to:
+ *
+ * \code
+ *  PHYSFS_unmount(oldDir);
+ * \endcode
+ *
+ * You must use this and not PHYSFS_unmount if binary compatibility with
+ *  PhysicsFS 1.0 is important (which it may not be for many people).
  *
  * \sa PHYSFS_addToSearchPath
  * \sa PHYSFS_getSearchPath
+ * \sa PHYSFS_unmount
  */
-PHYSFS_DECL int PHYSFS_removeFromSearchPath(const char *oldDir);
+PHYSFS_DECL int PHYSFS_removeFromSearchPath(const char *oldDir)
+                                            PHYSFS_DEPRECATED;
 
 
 /**
@@ -2476,6 +2490,28 @@
 /* Everything above this line is part of the PhysicsFS 2.0 API. */
 
 /**
+ * \fn int PHYSFS_unmount(const char *oldDir)
+ * \brief Remove a directory or archive from the search path.
+ *
+ * This is functionally equivalent to PHYSFS_removeFromSearchPath(), but that
+ *  function is deprecated to keep the vocabulary paired with PHYSFS_mount().
+ *
+ * This must be a (case-sensitive) match to a dir or archive already in the
+ *  search path, specified in platform-dependent notation.
+ *
+ * This call will fail (and fail to remove from the path) if the element still
+ *  has files open in it.
+ *
+ *    \param oldDir dir/archive to remove.
+ *   \return nonzero on success, zero on failure.
+ *            Specifics of the error can be gleaned from PHYSFS_getLastError().
+ *
+ * \sa PHYSFS_getSearchPath
+ * \sa PHYSFS_mount
+ */
+PHYSFS_DECL int PHYSFS_unmount(const char *oldDir);
+
+/**
  * \fn const PHYSFS_Allocator *PHYSFS_getAllocator(void)
  * \brief Discover the current allocator.
  *
--- a/test/test_physfs.c	Sun Aug 22 03:35:55 2010 -0400
+++ b/test/test_physfs.c	Sun Aug 22 03:43:22 2010 -0400
@@ -119,7 +119,7 @@
 
     /*printf("[%s], [%d]\n", args, appending);*/
 
-    if (PHYSFS_addToSearchPath(args, appending))
+    if (PHYSFS_mount(args, NULL, appending))
         printf("Successful.\n");
     else
         printf("Failure. reason: %s.\n", PHYSFS_getLastError());
@@ -189,7 +189,7 @@
         args[strlen(args) - 1] = '\0';
     } /* if */
 
-    if (PHYSFS_removeFromSearchPath(args))
+    if (PHYSFS_unmount(args))
         printf("Successful.\n");
     else
         printf("Failure. reason: %s.\n", PHYSFS_getLastError());
@@ -1024,6 +1024,7 @@
     { "addarchive",     cmd_addarchive,     2, "<archiveLocation> <append>" },
     { "mount",          cmd_mount,          3, "<archiveLocation> <mntpoint> <append>" },
     { "removearchive",  cmd_removearchive,  1, "<archiveLocation>"          },
+    { "unmount",        cmd_removearchive,  1, "<archiveLocation>"          },
     { "enumerate",      cmd_enumerate,      1, "<dirToEnumerate>"           },
     { "ls",             cmd_enumerate,      1, "<dirToEnumerate>"           },
     { "getlasterror",   cmd_getlasterror,   0, NULL                         },