* Fixed the broken nodeFlags semantics in BDirectory::Contains() (they are

flags, after all).
* This fixes the "Command-Tab" ie. switch to source/header command in Pe.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26932 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2008-08-11 18:16:33 +00:00
parent 8f38768e65
commit 872c3d3f6a
+12 -24
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007, Haiku Inc. * Copyright 2002-2008, Haiku Inc.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -486,41 +486,29 @@ BDirectory::Contains(const BEntry *entry, int32 nodeFlags) const
if (entry == NULL || !entry->Exists() || InitCheck() != B_OK) if (entry == NULL || !entry->Exists() || InitCheck() != B_OK)
return false; return false;
bool result = true; if (nodeFlags != B_ANY_NODE) {
// test the node kind // test the node kind
switch (nodeFlags) { bool result = false;
case B_FILE_NODE: if ((nodeFlags & B_FILE_NODE) != 0)
result = entry->IsFile(); result = entry->IsFile();
break; if (!result && (nodeFlags & B_DIRECTORY_NODE) != 0)
case B_DIRECTORY_NODE:
result = entry->IsDirectory(); result = entry->IsDirectory();
break; if (!result && (nodeFlags & B_SYMLINK_NODE) != 0)
case B_SYMLINK_NODE:
result = entry->IsSymLink(); result = entry->IsSymLink();
break; if (!result)
case B_ANY_NODE: return false;
break;
default:
result = false;
break;
} }
// If the directory is initialized, get the canonical paths of the dir and // If the directory is initialized, get the canonical paths of the dir and
// the entry and check, if the latter is a prefix of the first one. // the entry and check, if the latter is a prefix of the first one.
if (result) {
BPath dirPath(this, ".", true); BPath dirPath(this, ".", true);
BPath entryPath(entry); BPath entryPath(entry);
if (dirPath.InitCheck() == B_OK && entryPath.InitCheck() == B_OK) { if (dirPath.InitCheck() == B_OK && entryPath.InitCheck() != B_OK)
result = !strncmp(dirPath.Path(), entryPath.Path(), return false;
strlen(dirPath.Path()));
} else return !strncmp(dirPath.Path(), entryPath.Path(), strlen(dirPath.Path()));
result = false;
} }
return result;
}
// GetStatFor // GetStatFor
/*! \brief Returns the stat structure of the entry referred to by the supplied /*! \brief Returns the stat structure of the entry referred to by the supplied