eagleflo / mpyq

Python library for reading MPQ archives.
BSD 2-Clause "Simplified" License
100 stars 23 forks source link

MPQArchive.read_file Error #15

Closed GraylinKim closed 12 years ago

GraylinKim commented 12 years ago

Using the latest version off Pypi...

graylin@graylin-laptop:/home/sc2reader$ mpyq -x "/media/34A86959A8691A9E/Program Files/StarCraft II/Versions/Base19679/patch.SC2Archive"
Traceback (most recent call last):
  File "/usr/local/bin/mpyq", line 9, in <module>
    load_entry_point('mpyq==0.1.11', 'console_scripts', 'mpyq')()
  File "/usr/local/lib/python2.6/dist-packages/mpyq.py", line 399, in main
    archive.extract_to_disk()
  File "/usr/local/lib/python2.6/dist-packages/mpyq.py", line 249, in extract_to_disk
    for filename, data in self.extract().items():
  File "/usr/local/lib/python2.6/dist-packages/mpyq.py", line 239, in extract
    return dict((f, self.read_file(f)) for f in self.files)
  File "/usr/local/lib/python2.6/dist-packages/mpyq.py", line 239, in <genexpr>
    return dict((f, self.read_file(f)) for f in self.files)
  File "/usr/local/lib/python2.6/dist-packages/mpyq.py", line 218, in read_file
    file_data[:4*(sectors+1)])
struct.error: unpack requires a string argument of length 8

I'm not really sure how to diagnose this. You've got your own copy of the file you can hopefully replicate with. Do you have any ideas what is going on here?

eagleflo commented 12 years ago

This is caused by an empty file inside the archive. I'll add an check for empty files and ignore them during decompression.

This won't help much with this particular archive though: sadly none of the larger MPQ archives can be fully decompressed due to missing support for compression types. Perhaps I should add an option to ignore those files as well…

eagleflo commented 12 years ago

The first issue of empty files is fixed in arkx/mpyq@a8f586e279c990f564daaba885e772db640efb78.

I'll add an option to ignore files with unsupported compression types in a separate issue.