src/platform_posix.c
changeset 1073 b45193ab2033
parent 1054 57f4af811ffb
child 1098 4e86cec1143f
equal deleted inserted replaced
1072:6d3a91a5029b 1073:b45193ab2033
    95 
    95 
    96 
    96 
    97 char *__PHYSFS_platformGetUserDir(void)
    97 char *__PHYSFS_platformGetUserDir(void)
    98 {
    98 {
    99     char *retval = __PHYSFS_platformCopyEnvironmentVariable("HOME");
    99     char *retval = __PHYSFS_platformCopyEnvironmentVariable("HOME");
       
   100 
       
   101     /* if the environment variable was set, make sure it's really a dir. */
       
   102     if (retval != NULL)
       
   103     {
       
   104         struct stat statbuf;
       
   105         if ((stat(retval, &statbuf) == -1) || (S_ISDIR(statbuf.st_mode) == 0))
       
   106         {
       
   107             allocator.Free(retval);
       
   108             retval = NULL;
       
   109         } /* if */
       
   110     } /* if */
       
   111 
   100     if (retval == NULL)
   112     if (retval == NULL)
   101         retval = getUserDirByUID();
   113         retval = getUserDirByUID();
       
   114 
   102     return retval;
   115     return retval;
   103 } /* __PHYSFS_platformGetUserDir */
   116 } /* __PHYSFS_platformGetUserDir */
   104 
   117 
   105 
   118 
   106 int __PHYSFS_platformExists(const char *fname)
   119 int __PHYSFS_platformExists(const char *fname)