Skip to content
Permalink
Browse files
See if $HOME is bogus, and if so, use getpwuid() instead.
  • Loading branch information
icculus committed Mar 21, 2010
1 parent 72b232d commit efa498fd5db4218ed1c2b735a9402568d51458a1
Showing with 13 additions and 0 deletions.
  1. +13 −0 src/platform_posix.c
@@ -97,8 +97,21 @@ char *__PHYSFS_platformGetUserName(void)
char *__PHYSFS_platformGetUserDir(void)
{
char *retval = __PHYSFS_platformCopyEnvironmentVariable("HOME");

/* if the environment variable was set, make sure it's really a dir. */
if (retval != NULL)
{
struct stat statbuf;
if ((stat(retval, &statbuf) == -1) || (S_ISDIR(statbuf.st_mode) == 0))
{
allocator.Free(retval);
retval = NULL;
} /* if */
} /* if */

if (retval == NULL)
retval = getUserDirByUID();

return retval;
} /* __PHYSFS_platformGetUserDir */

0 comments on commit efa498f

Please sign in to comment.