浏览代码

[extractor/common] Fix dumping requests with long file abspath on Windows

Sergey M․ 11 年之前
父节点
当前提交
5f58165def
共有 1 个文件被更改,包括 6 次插入0 次删除
  1. 6 0
      youtube_dl/extractor/common.py

+ 6 - 0
youtube_dl/extractor/common.py

@@ -281,6 +281,12 @@ class InfoExtractor(object):
             raw_filename = basen + '.dump'
             raw_filename = basen + '.dump'
             filename = sanitize_filename(raw_filename, restricted=True)
             filename = sanitize_filename(raw_filename, restricted=True)
             self.to_screen('Saving request to ' + filename)
             self.to_screen('Saving request to ' + filename)
+            # Working around MAX_PATH limitation on Windows (see
+            # http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx)
+            if os.name == 'nt':
+                absfilepath = os.path.abspath(filename)
+                if len(absfilepath) > 259:
+                    filename = '\\\\?\\' + absfilepath
             with open(filename, 'wb') as outf:
             with open(filename, 'wb') as outf:
                 outf.write(webpage_bytes)
                 outf.write(webpage_bytes)