From 54cc53349d564f6849477c15902733327bd13869 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Fri, 9 Mar 2012 03:32:26 -0500 Subject: [PATCH] Cleaned up some __PHYSFS_platformStat() details. --- src/archiver_dir.c | 2 +- src/platform_posix.c | 22 ++++++++-------------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/archiver_dir.c b/src/archiver_dir.c index 5ad39233..e9eee89c 100644 --- a/src/archiver_dir.c +++ b/src/archiver_dir.c @@ -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 */ diff --git a/src/platform_posix.c b/src/platform_posix.c index 1ef6cb27..c14a1699 100644 --- a/src/platform_posix.c +++ b/src/platform_posix.c @@ -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); @@ -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 */