Consolidated MeltMind design decisions, S1 result review and Drive index; stdlib-only ZIP range-read census (624 logs) with SHA256SUMS. Review material only; not for main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
34 lines
1.4 KiB
Python
34 lines
1.4 KiB
Python
import sys,struct,collections
|
|
b=open(sys.argv[1],'rb').read()
|
|
i=b.rfind(b'PK\x05\x06'); print('eocd at',i)
|
|
# zip64 eocd
|
|
j=b.rfind(b'PK\x06\x06')
|
|
if j>=0:
|
|
n=struct.unpack('<Q',b[j+32:j+40])[0]; size=struct.unpack('<Q',b[j+40:j+48])[0]; off=struct.unpack('<Q',b[j+48:j+56])[0]
|
|
else:
|
|
n,size,off=struct.unpack('<HII',b[i+10:i+20])
|
|
print('entries',n,'cd size',size,'cd off',off)
|
|
total=32757812726; start=len(b)-(total-off)
|
|
p=start; ents=[]
|
|
while p<len(b) and b[p:p+4]==b'PK\x01\x02':
|
|
csz,usz=struct.unpack('<II',b[p+20:p+28]); nl,el,cl=struct.unpack('<HHH',b[p+28:p+34])
|
|
name=b[p+46:p+46+nl].decode('utf8','replace'); ex=b[p+46+nl:p+46+nl+el]
|
|
q=0
|
|
while q<len(ex):
|
|
hid,hs=struct.unpack('<HH',ex[q:q+4])
|
|
if hid==1:
|
|
v=ex[q+4:q+4+hs]; k=0
|
|
if usz==0xFFFFFFFF: usz=struct.unpack('<Q',v[k:k+8])[0];k+=8
|
|
if csz==0xFFFFFFFF: csz=struct.unpack('<Q',v[k:k+8])[0];k+=8
|
|
q+=4+hs
|
|
ents.append((name,usz,csz)); p+=46+nl+el+cl
|
|
print('parsed',len(ents))
|
|
ext=collections.Counter(); sz=collections.defaultdict(list)
|
|
for n_,u,c in ents:
|
|
e=n_.rsplit('.',1)[-1] if '.' in n_.split('/')[-1] else 'DIR'; ext[e]+=1; sz[e].append(u)
|
|
print(ext)
|
|
for e,v in sz.items():
|
|
if e=='DIR':continue
|
|
v=sorted(v); print(e,'n',len(v),'min',v[0],'med',v[len(v)//2],'max',v[-1],'sum GB',round(sum(v)/1e9,1))
|
|
for x in ents[:12]: print(x)
|