xar unarchiver (.xar, .pkg, .xip)
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix TOC parsing and remove SliceIO

+7 -23
+7 -23
czar.cr
··· 36 36 BZIP2 37 37 end 38 38 39 - class SliceIO < IO 40 - def initialize(@slice : Bytes) 41 - end 42 - 43 - def read(slice : Bytes) 44 - slice.size.times { |i| slice[i] = @slice[i] } 45 - @slice += slice.size 46 - slice.size 47 - end 48 - 49 - def write(slice : Bytes) 50 - slice.size.times { |i| @slice[i] = slice[i] } 51 - @slice += slice.size 52 - nil 53 - end 54 - 55 - def to_slice 56 - @slice 57 - end 58 - end 59 - 60 39 class XARHeader < BinaryParser 61 40 endian :big 62 41 string :magic, {count: 4} ··· 181 160 zfile.read toc_data 182 161 end 183 162 184 - xar_xml = XML.parse SliceIO.new toc_data 185 - toc = xml_select(xml_select(xar_xml, "xar").first, "toc").first 163 + xar_xml = XML.parse String.new(toc_data) 164 + xar_obj = xml_select(xar_xml, "xar") 165 + perror "empty xar object" if xar_obj.empty? 166 + 167 + tocs = xml_select(xar_obj.first, "toc") 168 + perror "empty TOC" if tocs.empty? 169 + toc = tocs.first 186 170 187 171 puts "reading TOC" 188 172 xar = XAR.new