Skip to content

Commit

Permalink
Cleaned up some __PHYSFS_platformStat() details.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Mar 9, 2012
1 parent de27c2a commit 54cc533
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/archiver_dir.c
Expand Up @@ -72,7 +72,7 @@ static PHYSFS_Io *doOpen(dvoid *opaque, const char *name,
allocator.Free(f);
if (io == NULL)
{
PHYSFS_Stat statbuf;
PHYSFS_Stat statbuf; /* !!! FIXME: this changes the error message. */
__PHYSFS_platformStat(f, fileExists, &statbuf);
return NULL;
} /* if */
Expand Down
22 changes: 8 additions & 14 deletions src/platform_posix.c
Expand Up @@ -205,13 +205,12 @@ void __PHYSFS_platformEnumerateFiles(const char *dirname,

strcpy(buf + dlen, ent->d_name);

if (__PHYSFS_platformStat(buf, &exists, &statbuf))
{
if (!exists)
continue;
else if (statbuf.filetype == PHYSFS_FILETYPE_SYMLINK)
continue;
} /* if */
if (!__PHYSFS_platformStat(buf, &exists, &statbuf))
continue;
else if (!exists)
continue; /* probably can't happen, but just in case. */
else if (statbuf.filetype == PHYSFS_FILETYPE_SYMLINK)
continue;
} /* if */

callback(callbackdata, origdir, ent->d_name);
Expand Down Expand Up @@ -389,14 +388,9 @@ int __PHYSFS_platformStat(const char *filename, int *exists, PHYSFS_Stat *st)
{
struct stat statbuf;

if (lstat(filename, &statbuf))
if (lstat(filename, &statbuf) == -1)
{
if (errno == ENOENT)
{
*exists = 0;
return 0;
} /* if */

*exists = (errno == ENOENT);
BAIL_MACRO(strerror(errno), 0);
} /* if */

Expand Down

0 comments on commit 54cc533

Please sign in to comment.