aboutsummaryrefslogtreecommitdiff
path: root/common/file.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'common/file.cpp')
-rw-r--r--common/file.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/common/file.cpp b/common/file.cpp
index 12461b7382..6228c6640b 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);
}