Removed __PHYSFS_platformRealPath().
authorRyan C. Gordon <icculus@icculus.org>
Sun, 11 Mar 2012 04:19:36 -0400
changeset 1213 050ee17c6e99
parent 1212 e3cd2449fe8e
child 1214 374be12cf9c8
Removed __PHYSFS_platformRealPath(). It was an ugly piece of code, didn't work on The Hurd (apparently), likely dangerous in its incomplete understanding of Windows paths, and only used in places that should have given us normalized, absolute paths in the first place anyhow.
docs/TODO.txt
src/physfs.c
src/physfs_internal.h
src/platform_beos.cpp
src/platform_macosx.c
src/platform_unix.c
src/platform_windows.c
--- a/docs/TODO.txt	Sun Mar 11 03:56:24 2012 -0400
+++ b/docs/TODO.txt	Sun Mar 11 04:19:36 2012 -0400
@@ -22,7 +22,6 @@
 - Deprecate PHYSFS_setSaneConfig(). It really should have been in the extras
   directory.
 - Clean up the sources to match my ever-changing coding style. :)
-- Remove realpath() for The Hurd, etc.
 - Get current CD list from windows without blocking? Is it possible?
 
 
--- a/src/physfs.c	Sun Mar 11 03:56:24 2012 -0400
+++ b/src/physfs.c	Sun Mar 11 04:19:36 2012 -0400
@@ -1050,14 +1050,6 @@
 static char *calculateUserDir(void)
 {
     char *retval = __PHYSFS_platformGetUserDir();
-    if (retval != NULL)
-    {
-        /* make sure it really exists and is normalized. */
-        char *ptr = __PHYSFS_platformRealPath(retval);
-        allocator.Free(retval);
-        retval = ptr;
-    } /* if */
-
     if (retval == NULL)
     {
         const char *dirsep = PHYSFS_getDirSeparator();
@@ -1174,8 +1166,6 @@
 
 int PHYSFS_init(const char *argv0)
 {
-    char *ptr;
-
     BAIL_IF_MACRO(initialized, ERR_IS_INITIALIZED, 0);
 
     if (!externalAllocator)
@@ -1191,12 +1181,6 @@
     baseDir = calculateBaseDir(argv0);
     BAIL_IF_MACRO(baseDir == NULL, NULL, 0);
 
-    /* !!! FIXME: only call this if we got this from argv0 (unreliable). */
-    ptr = __PHYSFS_platformRealPath(baseDir);
-    allocator.Free(baseDir);
-    BAIL_IF_MACRO(ptr == NULL, NULL, 0);
-    baseDir = ptr;
-
     BAIL_IF_MACRO(!appendDirSep(&baseDir), NULL, 0);
 
     userDir = calculateUserDir();
--- a/src/physfs_internal.h	Sun Mar 11 03:56:24 2012 -0400
+++ b/src/physfs_internal.h	Sun Mar 11 04:19:36 2012 -0400
@@ -1305,19 +1305,6 @@
 
 
 /*
- * Get the real physical path to a file. (path) is specified in
- *  platform-dependent notation, as should your return value be.
- *  All relative paths should be removed, leaving you with an absolute
- *  path. Symlinks should be resolved, too, so that the returned value is
- *  the most direct path to a file.
- * The return value will be deallocated with the standard C runtime free()
- *  function when the caller is done with it.
- * On error, return NULL and set the error message.
- */
-char *__PHYSFS_platformRealPath(const char *path);
-
-
-/*
  * Make a directory in the actual filesystem. (path) is specified in
  *  platform-dependent notation. On error, return zero and set the error
  *  message. Return non-zero on success.
--- a/src/platform_beos.cpp	Sun Mar 11 03:56:24 2012 -0400
+++ b/src/platform_beos.cpp	Sun Mar 11 04:19:36 2012 -0400
@@ -200,18 +200,6 @@
 } /* __PHYSFS_platformGetThreadID */
 
 
-char *__PHYSFS_platformRealPath(const char *path)
-{
-    BPath normalized(path, NULL, true);  /* force normalization of path. */
-    const char *resolved_path = normalized.Path();
-    BAIL_IF_MACRO(resolved_path == NULL, ERR_NO_SUCH_FILE, NULL);
-    char *retval = (char *) allocator.Malloc(strlen(resolved_path) + 1);
-    BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
-    strcpy(retval, resolved_path);
-    return(retval);
-} /* __PHYSFS_platformRealPath */
-
-
 void *__PHYSFS_platformCreateMutex(void)
 {
     return(new BLocker("PhysicsFS lock", true));
--- a/src/platform_macosx.c	Sun Mar 11 03:56:24 2012 -0400
+++ b/src/platform_macosx.c	Sun Mar 11 04:19:36 2012 -0400
@@ -288,32 +288,6 @@
 } /* __PHYSFS_platformCalcBaseDir */
 
 
-/* !!! FIXME */
-#define osxerr(x) x
-
-char *__PHYSFS_platformRealPath(const char *path)
-{
-    /* The symlink and relative path resolving happens in FSPathMakeRef() */
-    FSRef fsref;
-    CFURLRef cfurl = NULL;
-    CFStringRef cfstr = NULL;
-    char *retval = NULL;
-    OSStatus rc = osxerr(FSPathMakeRef((UInt8 *) path, &fsref, NULL));
-    BAIL_IF_MACRO(rc != noErr, NULL, NULL);
-
-    /* Now get it to spit out a full path. */
-    cfurl = CFURLCreateFromFSRef(cfallocator, &fsref);
-    BAIL_IF_MACRO(cfurl == NULL, ERR_OUT_OF_MEMORY, NULL);
-    cfstr = CFURLCopyFileSystemPath(cfurl, kCFURLPOSIXPathStyle);
-    CFRelease(cfurl);
-    BAIL_IF_MACRO(cfstr == NULL, ERR_OUT_OF_MEMORY, NULL);
-    retval = convertCFString(cfstr);
-    CFRelease(cfstr);
-
-    return retval;
-} /* __PHYSFS_platformRealPath */
-
-
 /* Platform allocator uses default CFAllocator at PHYSFS_init() time. */
 
 static CFAllocatorRef cfallocdef = NULL;
--- a/src/platform_unix.c	Sun Mar 11 03:56:24 2012 -0400
+++ b/src/platform_unix.c	Sun Mar 11 04:19:36 2012 -0400
@@ -290,21 +290,6 @@
 } /* __PHYSFS_platformCalcBaseDir */
 
 
-char *__PHYSFS_platformRealPath(const char *path)
-{
-    char resolved_path[MAXPATHLEN];
-    char *retval = NULL;
-
-    errno = 0;
-    BAIL_IF_MACRO(!realpath(path, resolved_path), strerror(errno), NULL);
-    retval = (char *) allocator.Malloc(strlen(resolved_path) + 1);
-    BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
-    strcpy(retval, resolved_path);
-
-    return retval;
-} /* __PHYSFS_platformRealPath */
-
-
 int __PHYSFS_platformSetDefaultAllocator(PHYSFS_Allocator *a)
 {
     return 0;  /* just use malloc() and friends. */
--- a/src/platform_windows.c	Sun Mar 11 03:56:24 2012 -0400
+++ b/src/platform_windows.c	Sun Mar 11 04:19:36 2012 -0400
@@ -444,20 +444,6 @@
 } /* __PHYSFS_platformCurrentDir */
 
 
-/* this could probably use a cleanup. */
-char *__PHYSFS_platformRealPath(const char *path)
-{
-    /*
-     * At this point, we only use this for the user and base dir,
-     *  and we already know those are RealPath'd by the OS for us.
-     */
-    char *retval = (char *) allocator.Malloc(strlen(path) + 1);
-    BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
-    strcpy(retval, path);
-    return retval;
-} /* __PHYSFS_platformRealPath */
-
-
 int __PHYSFS_platformMkDir(const char *path)
 {
     WCHAR *wpath;