Parcourir la source

fix broken implementation of join()

rdb il y a 14 ans
Parent
commit
8062339604
1 fichiers modifiés avec 13 ajouts et 2 suppressions
  1. 13 2
      direct/src/stdpy/file.py

+ 13 - 2
direct/src/stdpy/file.py

@@ -322,8 +322,19 @@ def walk(top, topdown = True, onerror = None, followlinks = True):
     if not topdown:
         yield (top, dirnames, filenames)
 
-def join(a, b):
-    return '%s/%s' % (a, b)
+def join(path, *args):
+    for part in args:
+        if part == '':
+            continue
+
+        if part.startswith('/'):
+            path = part
+        elif path.endswith('/'):
+            path = path + part
+        else:
+            path = '/'.join((path, part))
+
+    return path
 
 def isfile(path):
     return _vfs.isRegularFile(pm.Filename.fromOsSpecific(path))