From c57bd94f84e3bc03b04de2e95d6665785e3e44bc Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Tue, 13 Mar 2012 04:25:05 -0400 Subject: [PATCH] Apparently, __PHYSFS_platformCurrentDir() is dead code. --- src/physfs_internal.h | 10 ---------- src/platform_posix.c | 38 -------------------------------------- src/platform_windows.c | 25 ------------------------- 3 files changed, 73 deletions(-) diff --git a/src/physfs_internal.h b/src/physfs_internal.h index fdb320a4..5d28b733 100644 --- a/src/physfs_internal.h +++ b/src/physfs_internal.h @@ -1294,16 +1294,6 @@ void __PHYSFS_platformEnumerateFiles(const char *dirname, const char *origdir, void *callbackdata); - -/* - * Get the current working directory. The return value should be an - * absolute path in platform-dependent notation. The caller will deallocate - * the return value with allocator.Free() when it is done with it. - * On error, return NULL and set the error message. - */ -char *__PHYSFS_platformCurrentDir(void); - - /* * 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_posix.c b/src/platform_posix.c index d2b079ec..c14a1699 100644 --- a/src/platform_posix.c +++ b/src/platform_posix.c @@ -221,44 +221,6 @@ void __PHYSFS_platformEnumerateFiles(const char *dirname, } /* __PHYSFS_platformEnumerateFiles */ -char *__PHYSFS_platformCurrentDir(void) -{ - int allocSize = 64; - char *retval = NULL; - char *ptr; - - do - { - allocSize *= 2; - ptr = (char *) allocator.Realloc(retval, allocSize); - if (ptr == NULL) - { - if (retval != NULL) - allocator.Free(retval); - BAIL_MACRO(ERR_OUT_OF_MEMORY, NULL); - } /* if */ - - retval = ptr; - ptr = getcwd(retval, allocSize); - } while (ptr == NULL && errno == ERANGE); - - if (ptr == NULL && errno) - { - /* getcwd() failed , for example current directory not existing... */ - if (retval != NULL) - allocator.Free(retval); - BAIL_MACRO(ERR_NO_SUCH_FILE, NULL); - } /* if */ - - /* try to shrink buffer... */ - ptr = (char *) allocator.Realloc(retval, strlen(retval) + 1); - if (ptr != NULL) - retval = ptr; /* oh well if it failed. */ - - return retval; -} /* __PHYSFS_platformCurrentDir */ - - int __PHYSFS_platformMkDir(const char *path) { int rc; diff --git a/src/platform_windows.c b/src/platform_windows.c index 7fcd079e..e73fe004 100644 --- a/src/platform_windows.c +++ b/src/platform_windows.c @@ -557,31 +557,6 @@ void __PHYSFS_platformEnumerateFiles(const char *dirname, } /* __PHYSFS_platformEnumerateFiles */ -char *__PHYSFS_platformCurrentDir(void) -{ - char *retval = NULL; - WCHAR *wbuf = NULL; - DWORD buflen = 0; - - buflen = GetCurrentDirectoryW(buflen, NULL); - wbuf = (WCHAR *) __PHYSFS_smallAlloc((buflen + 2) * sizeof (WCHAR)); - BAIL_IF_MACRO(wbuf == NULL, ERR_OUT_OF_MEMORY, NULL); - GetCurrentDirectoryW(buflen, wbuf); - - if (wbuf[buflen - 2] == '\\') - wbuf[buflen - 1] = '\0'; /* just in case... */ - else - { - wbuf[buflen - 1] = '\\'; - wbuf[buflen] = '\0'; - } /* else */ - - retval = unicodeToUtf8Heap(wbuf); - __PHYSFS_smallFree(wbuf); - return retval; -} /* __PHYSFS_platformCurrentDir */ - - int __PHYSFS_platformMkDir(const char *path) { WCHAR *wpath;