From abffd3b3ab0d4c0af833696da3bcc819b2bf6aa8 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sun, 7 Sep 2008 21:47:01 +0000 Subject: Allow invoking FilesystemNode::getChild on non-dir nodes, by returning an invalid node in that case svn-id: r34429 --- common/fs.cpp | 6 +++--- common/fs.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/fs.cpp b/common/fs.cpp index d8f065b449..f7edf41711 100644 --- a/common/fs.cpp +++ b/common/fs.cpp @@ -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); } diff --git a/common/fs.h b/common/fs.h index 9163dbadce..b19abd0a80 100644 --- a/common/fs.h +++ b/common/fs.h @@ -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 -- cgit v1.2.3