You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2010/12/08 02:24:23 UTC
[lucy-commits] svn commit: r1043270 - /incubator/lucy/trunk/core/Lucy/Store/FSDirHandle.c
Author: marvin
Date: Wed Dec 8 01:24:23 2010
New Revision: 1043270
URL: http://svn.apache.org/viewvc?rev=1043270&view=rev
Log:
Fall back to stat() in FSDH_Entry_Is_Dir() if d_type is DT_UNKNOWN.
Modified:
incubator/lucy/trunk/core/Lucy/Store/FSDirHandle.c
Modified: incubator/lucy/trunk/core/Lucy/Store/FSDirHandle.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Store/FSDirHandle.c?rev=1043270&r1=1043269&r2=1043270&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Store/FSDirHandle.c (original)
+++ incubator/lucy/trunk/core/Lucy/Store/FSDirHandle.c Wed Dec 8 01:24:23 2010
@@ -116,22 +116,27 @@ FSDH_entry_is_dir(FSDirHandle *self)
struct dirent *sys_dir_entry = (struct dirent*)self->sys_dir_entry;
if (!sys_dir_entry) { return false; }
+ // If d_type is available, try to avoid a stat() call. If it's not, or if
+ // the type comes back as unknown, fall back to stat().
#ifdef CHY_HAS_DIRENT_D_TYPE
- return sys_dir_entry->d_type == DT_DIR ? true : false;
- #else
- {
- struct stat stat_buf;
- if (!self->fullpath) {
- self->fullpath = CB_new(CB_Get_Size(self->dir) + 20);
- }
- CB_setf(self->fullpath, "%o%s%o", self->dir, CHY_DIR_SEP,
- self->entry);
- if (stat((char*)CB_Get_Ptr8(self->fullpath), &stat_buf) != -1) {
- if (stat_buf.st_mode & S_IFDIR) return true;
- }
+ if (sys_dir_entry->d_type == DT_DIR) {
+ return true;
+ }
+ else if (sys_dir_entry->d_type != DT_UNKNOWN) {
return false;
}
- #endif // CHY_HAS_DIRENT_D_TYPE
+ #endif
+
+ struct stat stat_buf;
+ if (!self->fullpath) {
+ self->fullpath = CB_new(CB_Get_Size(self->dir) + 20);
+ }
+ CB_setf(self->fullpath, "%o%s%o", self->dir, CHY_DIR_SEP,
+ self->entry);
+ if (stat((char*)CB_Get_Ptr8(self->fullpath), &stat_buf) != -1) {
+ if (stat_buf.st_mode & S_IFDIR) { return true; }
+ }
+ return false;
}
bool_t