summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/wii/filesystem.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/wii/filesystem.py b/src/wii/filesystem.py
index b6b8103..0d40fe9 100644
--- a/src/wii/filesystem.py
+++ b/src/wii/filesystem.py
@@ -73,7 +73,7 @@ class WiiDirectory(WiiFSObject):
return None
- def resolvePath(self, path):
+ def resolvePath(self, path, createIfNotExists=False):
components = path.split('/')
currentDir = self
@@ -96,8 +96,18 @@ class WiiDirectory(WiiFSObject):
nextObj = currentDir.findByName(bit, False)
if nextObj is None:
- print("failed to resolve path %s: missing component %s" % (path, bit))
- return None
+ if not createIfNotExists:
+ print("failed to resolve path %s: missing component %s" % (path, bit))
+ return None
+ elif bit != '..':
+ # we must create it!
+ if len(components) == 0:
+ nextObj = WiiFile()
+ else:
+ nextObj = WiiDirectory()
+
+ nextObj.name = bit
+ currentDir.addChild(nextObj)
if len(components) == 0:
return nextObj