* Fixed and optimized the directory filter: since it already gets the stat

data, calling BNode::IsDirectory() is more expensive. Also, it did not
  traverse symlinks, and thus left them out.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29485 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2009-03-12 22:37:17 +00:00
parent 3f71e54926
commit 2c5ecffabf
+11 -3
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2004-2007, Haiku, Inc. All Rights Reserved. * Copyright 2004-2009, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -16,7 +16,6 @@
DirectoryRefFilter::DirectoryRefFilter() DirectoryRefFilter::DirectoryRefFilter()
: BRefFilter()
{ {
} }
@@ -25,7 +24,16 @@ bool
DirectoryRefFilter::Filter(const entry_ref *ref, BNode* node, struct stat *st, DirectoryRefFilter::Filter(const entry_ref *ref, BNode* node, struct stat *st,
const char *filetype) const char *filetype)
{ {
return node->IsDirectory(); if (S_ISDIR(st->st_mode))
return true;
if (S_ISLNK(st->st_mode)) {
// Traverse symlinks
BEntry entry(ref, true);
return entry.IsDirectory();
}
return false;
} }