mirror of
https://github.com/reactos/ccache.git
synced 2024-12-03 09:00:43 +00:00
eb874ae9fd
This is mainly done to facilitate introspection of manifest files in the future if we add support for hash algorithms with other hash sizes than 16 bytes.
62 lines
1.3 KiB
Python
Executable File
62 lines
1.3 KiB
Python
Executable File
#! /usr/bin/env python
|
|
|
|
import gzip
|
|
import sys
|
|
from struct import calcsize, unpack
|
|
|
|
f = gzip.open(sys.argv[1])
|
|
|
|
def get_fixstr(n):
|
|
return f.read(n)
|
|
|
|
def get_hash():
|
|
return f.read(hash_size).encode("hex")
|
|
|
|
def get_str():
|
|
result = ""
|
|
while True:
|
|
ch = f.read(1)
|
|
if ch == "\x00":
|
|
return result
|
|
result += ch
|
|
|
|
def get_uint8():
|
|
return unpack("!B", f.read(1))[0]
|
|
|
|
def get_uint16():
|
|
return unpack("!H", f.read(2))[0]
|
|
|
|
def get_uint32():
|
|
return unpack("!I", f.read(4))[0]
|
|
|
|
print "Magic: %s" % get_fixstr(4)
|
|
print "Version: %s" % get_uint8()
|
|
hash_size = get_uint8()
|
|
print "Hash size: %s" % hash_size
|
|
print "Reserved field: %s" % get_uint16()
|
|
|
|
n = get_uint32()
|
|
print "File paths (%d):" % n
|
|
for i in range(n):
|
|
print " %d: %s" % (i, get_str())
|
|
|
|
n = get_uint32()
|
|
print "File infos (%d):" % n
|
|
for i in range(n):
|
|
print " %d:" % i
|
|
print " Path index: %d" % get_uint32()
|
|
print " Hash: %s" % get_hash()
|
|
print " Size: %d" % get_uint32()
|
|
|
|
n = get_uint32()
|
|
print "Objects (%d):" % n
|
|
for i in range(n):
|
|
print " %d:" % i
|
|
print " File hash indexes:",
|
|
m = get_uint32()
|
|
for j in range(m):
|
|
print get_uint32(),
|
|
print
|
|
print " Hash: %s" % get_hash()
|
|
print " Size: %d" % get_uint32()
|