title: A error when unzip a zipped file that contains a very long filename on Windows system
body: <p>Here, I got a zipped file from Linux, now I want to unzip all files in my Windows PC. but I got a error that said the file name was too long to write to system. </p>
  
  <p>Now I just have a idea that before I write to disk, firstly I can change the filename in memory, then loop the file list, change the file name to a proper one, then write it to disk. how can I implement that in Python?    </p>
  
  <p>Does <em>zipfile</em> can help me? I try to write some codes to implement my solution here:   </p>
  
  <pre><code>import os
  import zipfile
  
  if __name__ == "__main__":
      zf = zipfile.ZipFile('c://jekyll-export.zip', 'r')
      # before I extract to local directory,
      # how can I change the file name? 
      zf.extractall()  # this can not works
  </code></pre>
  
  <hr>
  
  <p>Yes, I get a version that can works! but anyone can give a better solution? or suggestions?</p>
  
  <pre><code>if __name__ == "__main__":
      try:
          zf = zipfile.ZipFile('c://jekyll-export.zip', 'r')
      except Exception as e:
          print str(e)
      i = 0
      try:
          for info in zf.infolist():
              i += 1
              print info.filename
              original_name = urllib.unquote(info.filename)
              print original_name
              out_path = os.path.join(os.path.dirname(__file__), 'output') + original_name
              print type(out_path)
              #print os.path.dirname(os.path.dirname(out_path))
              if not os.path.exists(os.path.dirname(out_path)):
                  os.makedirs(os.path.dirname(out_path))
              buffer_size = 16 * 1024
              with zf.open(info) as fin, open(unicode(out_path, 'utf-8'), 'w') as fout:
                  while True:
                      buf = fin.read(buffer_size)
                      if not buf:
                          break
                      fout.write(buf)
      except (WindowsError, IOError) as e:
          print str(e)
  
      print i
  </code></pre>