Skip to content
Permalink
Browse files
Apparently, __PHYSFS_platformCurrentDir() is dead code.
  • Loading branch information
icculus committed Mar 13, 2012
1 parent 0ae446d commit c57bd94f84e3bc03b04de2e95d6665785e3e44bc
Showing with 0 additions and 73 deletions.
  1. +0 −10 src/physfs_internal.h
  2. +0 −38 src/platform_posix.c
  3. +0 −25 src/platform_windows.c
@@ -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
@@ -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;
@@ -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;

0 comments on commit c57bd94

Please sign in to comment.