diff options
author | Treeki <treeki@gmail.com> | 2011-11-06 00:04:17 +0100 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2011-11-06 00:04:17 +0100 |
commit | 8136cf1c533aec33ece4765cb3a3feda806450d3 (patch) | |
tree | 2e514e5364cd01d83f5de3aa5413a60f66429916 | |
parent | fc8b8e89b32155aa4f9236c36eee8bac248b52f2 (diff) | |
download | koopatlas-8136cf1c533aec33ece4765cb3a3feda806450d3.tar.gz koopatlas-8136cf1c533aec33ece4765cb3a3feda806450d3.zip |
added a create option to WiiDirectory.resolvePath
-rw-r--r-- | src/wii/filesystem.py | 16 |
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 |