From f1250dbfcb4fe0c7431c9b928e9f12c2d16aadd2 Mon Sep 17 00:00:00 2001 From: lolbot-iichan Date: Sat, 29 Jun 2019 18:56:57 +0300 Subject: COMMON: Implement createDirectory() method to Common::FSNode Added a simple wrapper for AbstractFSNode::create(true) since there was no way to create directories. --- common/fs.cpp | 11 +++++++++++ common/fs.h | 9 +++++++++ 2 files changed, 20 insertions(+) diff --git a/common/fs.cpp b/common/fs.cpp index 54fdf892f2..4b3ab21eb0 100644 --- a/common/fs.cpp +++ b/common/fs.cpp @@ -152,6 +152,17 @@ WriteStream *FSNode::createWriteStream() const { return _realNode->createWriteStream(); } +bool FSNode::createDirectory() const { + if (_realNode == nullptr) + return false; + + if (_realNode->exists()) { + return false; + } + + return _realNode->createDirectory(); +} + FSDirectory::FSDirectory(const FSNode &node, int depth, bool flat) : _node(node), _cached(false), _depth(depth), _flat(flat) { } diff --git a/common/fs.h b/common/fs.h index 6ff5c6eb8d..7041428fc8 100644 --- a/common/fs.h +++ b/common/fs.h @@ -230,6 +230,15 @@ public: * @return pointer to the stream object, 0 in case of a failure */ WriteStream *createWriteStream() const; + + /** + * Creates a directory referred by this node. This assumes that this + * node refers to non-existing directory. If this is not the case, + * false is returned. + * + * @return true if the directory was created, false otherwise. + */ + bool createDirectory() const; }; /** -- cgit v1.2.3