Class: Zip::ZipExtraField
Defined Under Namespace
Classes: Generic, IUnix, UniversalTime
Constant Summary
collapse
- ID_MAP =
{}
Instance Method Summary
collapse
Methods inherited from Hash
file, #ids, #rwd_table, #save, #subset, #to_i
Constructor Details
#initialize(binstr = nil) ⇒ ZipExtraField
start main of ZipExtraField < Hash
1292
1293
1294
|
# File 'lib/zip/zip.rb', line 1292
def initialize(binstr = nil)
binstr and merge(binstr)
end
|
Instance Method Details
#c_dir_length ⇒ Object
Also known as:
c_dir_size
1360
1361
1362
|
# File 'lib/zip/zip.rb', line 1360
def c_dir_length
to_c_dir_bin.length
end
|
#create(name) ⇒ Object
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
|
# File 'lib/zip/zip.rb', line 1329
def create(name)
field_class = nil
ID_MAP.each { |id, klass|
if klass.name == name
field_class = klass
break
end
}
if ! field_class
raise ZipError, "Unknown extra field '#{name}'"
end
self[name] = field_class.new()
end
|
#local_length ⇒ Object
Also known as:
local_size, length, size
1363
1364
1365
|
# File 'lib/zip/zip.rb', line 1363
def local_length
to_local_bin.length
end
|
#merge(binstr) ⇒ Object
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
|
# File 'lib/zip/zip.rb', line 1296
def merge(binstr)
binstr == "" and return
i = 0
while i < binstr.length
id = binstr[i,2]
len = binstr[i+2,2].to_s.unpack("v")[0]
if id && ID_MAP.member?(id)
field_name = ID_MAP[id].name
if self.member?(field_name)
self[field_name].mergea(binstr[i, len+4])
else
field_obj = ID_MAP[id].new(binstr[i, len+4])
self[field_name] = field_obj
end
elsif id
unless self["Unknown"]
s = ""
class << s
alias_method :to_c_dir_bin, :to_s
alias_method :to_local_bin, :to_s
end
self["Unknown"] = s
end
if ! len || len+4 > binstr[i..-1].length
self["Unknown"] << binstr[i..-1]
break;
end
self["Unknown"] << binstr[i, len+4]
end
i += len+4
end
end
|
#to_c_dir_bin ⇒ Object
1352
1353
1354
1355
1356
1357
1358
|
# File 'lib/zip/zip.rb', line 1352
def to_c_dir_bin
s = ""
each { |k, v|
s << v.to_c_dir_bin
}
s
end
|
#to_local_bin ⇒ Object
Also known as:
to_s
1343
1344
1345
1346
1347
1348
1349
|
# File 'lib/zip/zip.rb', line 1343
def to_local_bin
s = ""
each { |k, v|
s << v.to_local_bin
}
s
end
|