diff options
author | Cameron Cawley | 2019-07-02 18:08:33 +0100 |
---|---|---|
committer | Filippos Karapetis | 2019-08-11 22:15:54 +0300 |
commit | aca627bec7b407790d78a64df984344ff454c15b (patch) | |
tree | 8aa18208291f43525b79606fa891cb564fa84892 /common/fs.cpp | |
parent | 04c57babbc06dfba33a5597a83e80c27c1ba6be9 (diff) | |
download | scummvm-rg350-aca627bec7b407790d78a64df984344ff454c15b.tar.gz scummvm-rg350-aca627bec7b407790d78a64df984344ff454c15b.tar.bz2 scummvm-rg350-aca627bec7b407790d78a64df984344ff454c15b.zip |
COMMON: Implement FSNode::createDirectoryRecursive()
Diffstat (limited to 'common/fs.cpp')
-rw-r--r-- | common/fs.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/common/fs.cpp b/common/fs.cpp index d27de48370..2ba64099b4 100644 --- a/common/fs.cpp +++ b/common/fs.cpp @@ -168,6 +168,27 @@ bool FSNode::createDirectory() const { return _realNode->createDirectory(); } +bool FSNode::createDirectoryRecursive() const { + if (_realNode == nullptr) + return false; + + if (_realNode->exists()) { + if (!_realNode->isDirectory()) { + warning("FSNode::createDirectoryRecursive: '%s' is a file", _realNode->getName().c_str()); + return false; + } else { + return true; + } + } + + FSNode parent = getParent(); + assert(parent.getPath() != _realNode->getPath()); + if (!parent.createDirectoryRecursive()) + return false; + + return _realNode->createDirectory(); +} + FSDirectory::FSDirectory(const FSNode &node, int depth, bool flat) : _node(node), _cached(false), _depth(depth), _flat(flat) { } |