From 611aeec61b40bed82a8a17f2454b8404cdc64996 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 11 Mar 2012 04:19:36 -0400 Subject: [PATCH] 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 | 1 - src/physfs.c | 16 ---------------- src/physfs_internal.h | 13 ------------- src/platform_beos.cpp | 12 ------------ src/platform_macosx.c | 26 -------------------------- src/platform_unix.c | 15 --------------- src/platform_windows.c | 14 -------------- 7 files changed, 97 deletions(-) diff --git a/docs/TODO.txt b/docs/TODO.txt index 2901e21..cec1976 100644 --- a/docs/TODO.txt +++ b/docs/TODO.txt @@ -22,7 +22,6 @@ From http://icculus.org/pipermail/physfs/2009-March/000698.html ... - 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? diff --git a/src/physfs.c b/src/physfs.c index bfae0cb..595b437 100644 --- a/src/physfs.c +++ b/src/physfs.c @@ -1050,14 +1050,6 @@ static int freeDirHandle(DirHandle *dh, FileHandle *openList) 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 @@ static void setDefaultAllocator(void); int PHYSFS_init(const char *argv0) { - char *ptr; - BAIL_IF_MACRO(initialized, ERR_IS_INITIALIZED, 0); if (!externalAllocator) @@ -1191,12 +1181,6 @@ int PHYSFS_init(const char *argv0) 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(); diff --git a/src/physfs_internal.h b/src/physfs_internal.h index ca472f8..2a7be6c 100644 --- a/src/physfs_internal.h +++ b/src/physfs_internal.h @@ -1304,19 +1304,6 @@ void __PHYSFS_platformEnumerateFiles(const char *dirname, char *__PHYSFS_platformCurrentDir(void); -/* - * 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 diff --git a/src/platform_beos.cpp b/src/platform_beos.cpp index 0f454f6..45faa00 100644 --- a/src/platform_beos.cpp +++ b/src/platform_beos.cpp @@ -200,18 +200,6 @@ void *__PHYSFS_platformGetThreadID(void) } /* __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)); diff --git a/src/platform_macosx.c b/src/platform_macosx.c index 06cb8ab..ff818c2 100644 --- a/src/platform_macosx.c +++ b/src/platform_macosx.c @@ -288,32 +288,6 @@ char *__PHYSFS_platformCalcBaseDir(const char *argv0) } /* __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; diff --git a/src/platform_unix.c b/src/platform_unix.c index bd21292..4e65b61 100644 --- a/src/platform_unix.c +++ b/src/platform_unix.c @@ -290,21 +290,6 @@ char *__PHYSFS_platformCalcBaseDir(const char *argv0) } /* __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. */ diff --git a/src/platform_windows.c b/src/platform_windows.c index 8872723..57622e4 100644 --- a/src/platform_windows.c +++ b/src/platform_windows.c @@ -444,20 +444,6 @@ char *__PHYSFS_platformCurrentDir(void) } /* __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;