method
header
v2_5_5 -
Show latest stable
-
0 notes -
Class: TarTestCase
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378
- 1_9_2_180
- 1_9_3_125 (0)
- 1_9_3_392 (0)
- 2_1_10 (0)
- 2_2_9 (0)
- 2_4_6 (0)
- 2_5_5 (0)
- 2_6_3 (0)
- What's this?
header(type, fname, dname, length, mode, mtime, checksum = nil, linkname = "")
public
Hide source
# File lib/rubygems/package/tar_test_case.rb, line 75 def header(type, fname, dname, length, mode, mtime, checksum = nil, linkname = "") checksum ||= " " * 8 arr = [ # struct tarfile_entry_posix ASCIIZ(fname, 100), # char name[100]; ASCII + (Z unless filled) Z(to_oct(mode, 7)), # char mode[8]; 0 padded, octal null Z(to_oct(0, 7)), # char uid[8]; ditto Z(to_oct(0, 7)), # char gid[8]; ditto Z(to_oct(length, 11)), # char size[12]; 0 padded, octal, null Z(to_oct(mtime, 11)), # char mtime[12]; 0 padded, octal, null checksum, # char checksum[8]; 0 padded, octal, null, space type, # char typeflag[1]; file: "0" dir: "5" ASCIIZ(linkname, 100), # char linkname[100]; ASCII + (Z unless filled) "ustar\00"", # char magic[6]; "ustar\0" "00", # char version[2]; "00" ASCIIZ("wheel", 32), # char uname[32]; ASCIIZ ASCIIZ("wheel", 32), # char gname[32]; ASCIIZ Z(to_oct(0, 7)), # char devmajor[8]; 0 padded, octal, null Z(to_oct(0, 7)), # char devminor[8]; 0 padded, octal, null ASCIIZ(dname, 155) # char prefix[155]; ASCII + (Z unless filled) ] format = "C100C8C8C8C12C12C8CC100C6C2C32C32C8C8C155" h = if RUBY_VERSION >= "1.9" then arr.join else arr = arr.join("").split(//).map{|x| x[0]} arr.pack format end ret = h + "\00"" * (512 - h.size) assert_equal(512, ret.size) ret end