* 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.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -486,42 +486,30 @@ 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
|
bool result = false;
|
||||||
switch (nodeFlags) {
|
if ((nodeFlags & B_FILE_NODE) != 0)
|
||||||
case B_FILE_NODE:
|
|
||||||
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) {
|
return false;
|
||||||
result = !strncmp(dirPath.Path(), entryPath.Path(),
|
|
||||||
strlen(dirPath.Path()));
|
|
||||||
} else
|
|
||||||
result = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return !strncmp(dirPath.Path(), entryPath.Path(), strlen(dirPath.Path()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 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
|
||||||
path name.
|
path name.
|
||||||
|
|||||||
Reference in New Issue
Block a user