16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/zip64/debug.rb', line 16
def zip_debug(arg)
File.open(arg, "rb") do |fp|
until fp.eof?
until fp.eof? or (fp.tell%2).zero?
fp.getc
end
bs = fp.tell
STDOUT.write(sprintf(".%-16i", bs))
sig = fp.read(4).unpack('V').first
klass = find_block_type sig
if klass
o = klass.read_from(fp, 1)
o.signature = sig
o.describe(STDOUT)
case o
when Zip64::LocalFileHeader
filename = fp.read(o.filename_len)
= fp.read(o.)
data_len = o.data_len
unless .empty?
= StringIO.new()
until .eof?
esig = .read(2).unpack('v').first
if eklass = find_block_type(esig)
e = eklass.read_from(, 1)
e.signature = sig
e.describe(STDOUT)
end
end
end
data = fp.read(data_len)
p [:filename, filename]
p [:extra, ]
if data.size > 50
data = data[0..50]+"(#{data.size} bytes, truncated)"
end
p [:data, data]
when Zip64::CDFileHeader
filename = fp.read(o.filename_len)
= fp.read(o.)
= fp.read(o.)
p [:filename, filename]
p [:extra, ]
p [:comment, ]
end
else
puts sprintf('%16s %16i', sig.to_s(16), sig) if sig
end
end
end
end
|