[Scummvm-git-logs] scummvm master -> 410923351b5c08395828ef42ebf1a74dd891e727

sev- sev at scummvm.org
Sun Sep 15 00:07:49 CEST 2019


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
410923351b Revert "COMMON: Implement FSNode::createDirectoryRecursive()"


Commit: 410923351b5c08395828ef42ebf1a74dd891e727
    https://github.com/scummvm/scummvm/commit/410923351b5c08395828ef42ebf1a74dd891e727
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2019-09-15T00:07:46+02:00

Commit Message:
Revert "COMMON: Implement FSNode::createDirectoryRecursive()"

This reverts commit aca627bec7b407790d78a64df984344ff454c15b.

Changed paths:
    backends/saves/default/default-saves.cpp
    common/file.cpp
    common/fs.cpp
    common/fs.h


diff --git a/backends/saves/default/default-saves.cpp b/backends/saves/default/default-saves.cpp
index ee54557..17e8881 100644
--- a/backends/saves/default/default-saves.cpp
+++ b/backends/saves/default/default-saves.cpp
@@ -63,7 +63,7 @@ DefaultSaveFileManager::DefaultSaveFileManager(const Common::String &defaultSave
 void DefaultSaveFileManager::checkPath(const Common::FSNode &dir) {
 	clearError();
 	if (!dir.exists()) {
-		if (!dir.createDirectoryRecursive()) {
+		if (!dir.createDirectory()) {
 			setError(Common::kPathDoesNotExist, "Failed to create directory '"+dir.getPath()+"'");
 		}
 	} else if (!dir.isDirectory()) {
diff --git a/common/file.cpp b/common/file.cpp
index 12461b7..6228c66 100644
--- a/common/file.cpp
+++ b/common/file.cpp
@@ -155,10 +155,24 @@ bool DumpFile::open(const String &filename, bool createPath) {
 	assert(!filename.empty());
 	assert(!_handle);
 
-	FSNode node(filename);
-	if (createPath)
-		node.getParent().createDirectoryRecursive();
+	if (createPath) {
+		for (uint32 i = 0; i < filename.size(); ++i) {
+			if (filename[i] == '/' || filename[i] == '\\') {
+				Common::String subpath = filename;
+				subpath.erase(i);
+				if (subpath.empty()) continue;
+				AbstractFSNode *node = g_system->getFilesystemFactory()->makeFileNodePath(subpath);
+				if (node->exists()) {
+					delete node;
+					continue;
+				}
+				if (!node->createDirectory()) warning("DumpFile: unable to create directories from path prefix");
+				delete node;
+			}
+		}
+	}
 
+	FSNode node(filename);
 	return open(node);
 }
 
diff --git a/common/fs.cpp b/common/fs.cpp
index 2ba6409..d27de48 100644
--- a/common/fs.cpp
+++ b/common/fs.cpp
@@ -168,27 +168,6 @@ 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) {
 }
diff --git a/common/fs.h b/common/fs.h
index e8c23f8..7041428 100644
--- a/common/fs.h
+++ b/common/fs.h
@@ -239,14 +239,6 @@ public:
 	 * @return true if the directory was created, false otherwise.
 	 */
 	bool createDirectory() const;
-
-	/**
-	 * Creates a directory referred by this node. The parent directory
-	 * will also be created if it doesn't exist.
-	 *
-	 * @return true if the directory was created, false otherwise.
-	 */
-	bool createDirectoryRecursive() const;
 };
 
 /**





More information about the Scummvm-git-logs mailing list