forked from qt-creator/qt-creator
FileName: Fix isChildOf for some corner cases
empty directory has no children, and root directory was not handled correctly Change-Id: I1936eab96aef0a3be462f705c60f1f26995be68b Reviewed-by: Daniel Teske <daniel.teske@digia.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
c29123158a
commit
34354148db
@@ -526,10 +526,16 @@ bool FileName::operator>=(const FileName &other) const
|
||||
/// \returns whether FileName is a child of \a s
|
||||
bool FileName::isChildOf(const FileName &s) const
|
||||
{
|
||||
if (s.isEmpty())
|
||||
return false;
|
||||
if (!QString::startsWith(s, cs))
|
||||
return false;
|
||||
if (size() <= s.size())
|
||||
return false;
|
||||
// s is root, '/' was already tested in startsWith
|
||||
if (s.QString::endsWith(QLatin1Char('/')))
|
||||
return true;
|
||||
// s is a directory, next character should be '/' (/tmpdir is NOT a child of /tmp)
|
||||
return at(s.size()) == QLatin1Char('/');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user