* 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:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2007, Haiku Inc.
|
||||
* Copyright 2002-2008, Haiku Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@@ -486,42 +486,30 @@ BDirectory::Contains(const BEntry *entry, int32 nodeFlags) const
|
||||
if (entry == NULL || !entry->Exists() || InitCheck() != B_OK)
|
||||
return false;
|
||||
|
||||
bool result = true;
|
||||
|
||||
// test the node kind
|
||||
switch (nodeFlags) {
|
||||
case B_FILE_NODE:
|
||||
if (nodeFlags != B_ANY_NODE) {
|
||||
// test the node kind
|
||||
bool result = false;
|
||||
if ((nodeFlags & B_FILE_NODE) != 0)
|
||||
result = entry->IsFile();
|
||||
break;
|
||||
case B_DIRECTORY_NODE:
|
||||
if (!result && (nodeFlags & B_DIRECTORY_NODE) != 0)
|
||||
result = entry->IsDirectory();
|
||||
break;
|
||||
case B_SYMLINK_NODE:
|
||||
if (!result && (nodeFlags & B_SYMLINK_NODE) != 0)
|
||||
result = entry->IsSymLink();
|
||||
break;
|
||||
case B_ANY_NODE:
|
||||
break;
|
||||
|
||||
default:
|
||||
result = false;
|
||||
break;
|
||||
if (!result)
|
||||
return false;
|
||||
}
|
||||
|
||||
// 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.
|
||||
if (result) {
|
||||
BPath dirPath(this, ".", true);
|
||||
BPath entryPath(entry);
|
||||
if (dirPath.InitCheck() == B_OK && entryPath.InitCheck() == B_OK) {
|
||||
result = !strncmp(dirPath.Path(), entryPath.Path(),
|
||||
strlen(dirPath.Path()));
|
||||
} else
|
||||
result = false;
|
||||
}
|
||||
BPath dirPath(this, ".", true);
|
||||
BPath entryPath(entry);
|
||||
if (dirPath.InitCheck() == B_OK && entryPath.InitCheck() != B_OK)
|
||||
return false;
|
||||
|
||||
return result;
|
||||
return !strncmp(dirPath.Path(), entryPath.Path(), strlen(dirPath.Path()));
|
||||
}
|
||||
|
||||
|
||||
// GetStatFor
|
||||
/*! \brief Returns the stat structure of the entry referred to by the supplied
|
||||
path name.
|
||||
|
||||
Reference in New Issue
Block a user