Fix os.makedirs in Windows
[youtube-dl.git] / youtube-dl
index 7ac27b5..153d413 100755 (executable)
@@ -14,7 +14,7 @@ __author__  = (
        )
 
 __license__ = 'Public Domain'
-__version__ = '2011.08.28-phihag'
+__version__ = '2011.09.06-phihag'
 
 UPDATE_URL = 'https://raw.github.com/phihag/youtube-dl/master/youtube-dl'
 
@@ -456,16 +456,6 @@ class FileDownloader(object):
                self.params = params
 
        @staticmethod
-       def pmkdir(filename):
-               """Create directory components in filename. Similar to Unix "mkdir -p"."""
-               components = filename.split(os.sep)
-               aggregate = [os.sep.join(components[0:x]) for x in xrange(1, len(components))]
-               aggregate = ['%s%s' % (x, os.sep) for x in aggregate] # Finish names with separator
-               for dir in aggregate:
-                       if not os.path.exists(dir):
-                               os.mkdir(dir)
-
-       @staticmethod
        def format_bytes(bytes):
                if bytes is None:
                        return 'N/A'
@@ -721,7 +711,9 @@ class FileDownloader(object):
                        return
 
                try:
-                       self.pmkdir(filename)
+                       dn = os.path.dirname(filename)
+                       if dn != '' and not os.path.exists(dn):
+                               os.makedirs(dn)
                except (OSError, IOError), err:
                        self.trouble(u'ERROR: unable to create directories: %s' % str(err))
                        return