From 8136cf1c533aec33ece4765cb3a3feda806450d3 Mon Sep 17 00:00:00 2001 From: Treeki Date: Sun, 6 Nov 2011 00:04:17 +0100 Subject: added a create option to WiiDirectory.resolvePath --- src/wii/filesystem.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/wii') 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 -- cgit v1.2.3