Skip to content
Permalink
Browse files
Added PHYSFS_unmount(), deprecated addToSearchPath and removeFromSear…
…chPath.
  • Loading branch information
icculus committed Aug 22, 2010
1 parent c306d73 commit c1969d0595c20c5b91e12c8af21b7efdf32c72d3
Showing with 63 additions and 19 deletions.
  1. +1 −0 extras/physfs-swig.i
  2. +11 −5 src/physfs.c
  3. +48 −12 src/physfs.h
  4. +3 −2 test/test_physfs.c
@@ -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"
@@ -1003,6 +1003,12 @@ int PHYSFS_addToSearchPath(const char *newDir, int appendToPath)


int PHYSFS_removeFromSearchPath(const char *oldDir)
{
return PHYSFS_unmount(oldDir);
} /* PHYSFS_removeFromSearchPath */


int PHYSFS_unmount(const char *oldDir)
{
DirHandle *i;
DirHandle *prev = NULL;
@@ -1030,7 +1036,7 @@ int PHYSFS_removeFromSearchPath(const char *oldDir)
} /* for */

BAIL_MACRO_MUTEX(ERR_NOT_IN_SEARCH_PATH, stateLock, 0);
} /* PHYSFS_removeFromSearchPath */
} /* PHYSFS_unmount */


char **PHYSFS_getSearchPath(void)
@@ -1081,7 +1087,7 @@ static void setSaneCfgAddPath(const char *i, const size_t l, const char *dirsep,
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,19 +1139,19 @@ int PHYSFS_setSaneConfig(const char *organization, const char *appName,
} /* 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)
{
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 */
@@ -800,8 +800,14 @@ PHYSFS_DECL int PHYSFS_setWriteDir(const char *newDir);
* \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 @@ PHYSFS_DECL int PHYSFS_setWriteDir(const char *newDir);
* \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.
* \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 call will fail (and fail to remove from the path) if the element still
* has files open in it.
* This function is equivalent to:
*
* \param oldDir dir/archive to remove.
* \return nonzero on success, zero on failure.
* Specifics of the error can be gleaned from PHYSFS_getLastError().
* \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;


/**
@@ -2475,6 +2489,28 @@ PHYSFS_DECL void PHYSFS_utf8FromLatin1(const char *src, char *dst,

/* 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.
@@ -119,7 +119,7 @@ static int cmd_addarchive(char *args)

/*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 @@ static int cmd_removearchive(char *args)
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 @@ static const command_info commands[] =
{ "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 },

0 comments on commit c1969d0

Please sign in to comment.