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.
This commit is contained in:
Ryan C. Gordon 2012-03-11 04:19:36 -04:00
parent 2aa0c5a278
commit 611aeec61b
7 changed files with 0 additions and 97 deletions

View File

@ -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?

View File

@ -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();

View File

@ -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

View File

@ -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));

View File

@ -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;

View File

@ -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. */

View File

@ -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;