Allow invoking FilesystemNode::getChild on non-dir nodes, by returning an invalid node in that case

svn-id: r34429
This commit is contained in:
Max Horn 2008-09-07 21:47:01 +00:00
parent 7aaf6139e2
commit abffd3b3ab
2 changed files with 4 additions and 4 deletions

View File

@ -62,10 +62,10 @@ bool FilesystemNode::exists() const {
}
FilesystemNode FilesystemNode::getChild(const Common::String &n) const {
if (_realNode == 0)
return *this;
// If this node is invalid or not a directory, return an invalid node
if (_realNode == 0 || !_realNode->isDirectory())
return FilesystemNode();
assert(_realNode->isDirectory());
AbstractFilesystemNode *node = _realNode->getChild(n);
return FilesystemNode(node);
}

View File

@ -103,7 +103,7 @@ public:
/**
* Create a new node referring to a child node of the current node, which
* must be a directory node (an assertion is triggered otherwise).
* must be a directory node (otherwise an invalid node is returned).
* If a child matching the name exists, a normal node for it is returned.
* If no child with the name exists, a node for it is still returned,
* but exists() will return 'false' for it. This node can however be used