aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlolbot-iichan2019-06-29 18:56:57 +0300
committerFilippos Karapetis2019-08-11 22:15:54 +0300
commitf1250dbfcb4fe0c7431c9b928e9f12c2d16aadd2 (patch)
tree6c9642d3be917e45de8ddb38f2ac2a3c3506bf1c
parentd8dc31a6730dff72189b5ab240a5af06ab5dd135 (diff)
downloadscummvm-rg350-f1250dbfcb4fe0c7431c9b928e9f12c2d16aadd2.tar.gz
scummvm-rg350-f1250dbfcb4fe0c7431c9b928e9f12c2d16aadd2.tar.bz2
scummvm-rg350-f1250dbfcb4fe0c7431c9b928e9f12c2d16aadd2.zip
COMMON: Implement createDirectory() method to Common::FSNode
Added a simple wrapper for AbstractFSNode::create(true) since there was no way to create directories.
-rw-r--r--common/fs.cpp11
-rw-r--r--common/fs.h9
2 files changed, 20 insertions, 0 deletions
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;
};
/**