Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions py7zlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,13 @@ def _read64Bit(self, file):
value = (bytes and reduce(lambda x, y: x << 8 | y, bytes)) or 0
highpart = b & (mask - 1)
return value + (highpart << (i * 8))

mask >>= 1

bytes = array('B', file.read(8))
bytes.reverse()
value = (bytes and reduce(lambda x, y: x << 8 | y, bytes)) or 0
return value

def _readBoolean(self, file, count, checkall=0):
if checkall:
alldefined = file.read(1)
Expand Down Expand Up @@ -270,7 +274,7 @@ def __init__(self, file):
id = file.read(1)

if id == PROPERTY_CRC:
self.crcs = [self._read64Bit(file) for x in xrange(self.numstreams)]
digests = UnpackDigests(file, self.numstreams)
id = file.read(1)

if id != PROPERTY_END:
Expand Down Expand Up @@ -1068,7 +1072,7 @@ def list(self, verbose=True, file=sys.stdout):

for f in self.files:
extra = (f.compressed and '%10d ' % (f.compressed)) or ' '
file.write('%10d%s%.8x %s\n' % (f.size, extra, f.digest, f.filename))
file.write('%10d%s%.8x %s\n' % (f.size, extra, f.digest or 0, f.filename))

if __name__ == '__main__':
f = Archive7z(open('test.7z', 'rb'))
Expand Down