]> granicus.if.org Git - python/commitdiff
More tweaks to 'mkpath()':
authorGreg Ward <gward@python.net>
Wed, 29 Sep 1999 12:14:16 +0000 (12:14 +0000)
committerGreg Ward <gward@python.net>
Wed, 29 Sep 1999 12:14:16 +0000 (12:14 +0000)
  - deal with empty tail from os.path.split() (eg. from trailing slash,
    or backslash, or whatever)
  - check PATH_CREATED hash inside loop as well

Lib/distutils/util.py

index 85b04e7a809ec3a6bcfe530c4a86c3f707a1b91f..aee95d366813ec3b4a00b5f70c723e24a87dfedc 100644 (file)
@@ -43,6 +43,8 @@ def mkpath (name, mode=0777, verbose=0, dry_run=0):
         return
 
     (head, tail) = os.path.split (name)
+    if not tail:                        # in case 'name' has trailing slash
+        (head, tail) = os.path.split (head)
     tails = [tail]                      # stack of lone dirs to create
     
     while head and tail and not os.path.isdir (head):
@@ -59,6 +61,9 @@ def mkpath (name, mode=0777, verbose=0, dry_run=0):
     for d in tails:
         #print "head = %s, d = %s: " % (head, d),
         head = os.path.join (head, d)
+        if PATH_CREATED.get (head):
+            continue
+
         if verbose:
             print "creating", head