Class | Archive::Tar::PosixHeader |
In: |
lib/archive/tar/minitar.rb
|
Parent: | Object |
Implements the POSIX tar header as a Ruby class. The structure of the POSIX tar header is:
struct tarfile_entry_posix { // pack/unpack char name[100]; // ASCII (+ Z unless filled) a100/Z100 char mode[8]; // 0 padded, octal, null a8 /A8 char uid[8]; // ditto a8 /A8 char gid[8]; // ditto a8 /A8 char size[12]; // 0 padded, octal, null a12 /A12 char mtime[12]; // 0 padded, octal, null a12 /A12 char checksum[8]; // 0 padded, octal, null, space a8 /A8 char typeflag[1]; // see below a /a char linkname[100]; // ASCII + (Z unless filled) a100/Z100 char magic[6]; // "ustar\0" a6 /A6 char version[2]; // "00" a2 /A2 char uname[32]; // ASCIIZ a32 /Z32 char gname[32]; // ASCIIZ a32 /Z32 char devmajor[8]; // 0 padded, octal, null a8 /A8 char devminor[8]; // 0 padded, octal, null a8 /A8 char prefix[155]; // ASCII (+ Z unless filled) a155/Z155 };
The typeflag may be one of the following known values:
"0": | Regular file. NULL should be treated as a synonym, for compatibility purposes. |
"1": | Hard link. |
"2": | Symbolic link. |
"3": | Character device node. |
"4": | Block device node. |
"5": | Directory. |
"6": | FIFO node. |
"7": | Reserved. |
POSIX indicates that "A POSIX-compliant implementation must treat any unrecognized typeflag value as a regular file."
FIELDS | = | %w(name mode uid gid size mtime checksum typeflag linkname) + %w(magic version uname gname devmajor devminor prefix) |
HEADER_PACK_FORMAT | = | "a100a8a8a8a12a12a7aaa100a6a2a32a32a8a8a155" |
HEADER_UNPACK_FORMAT | = | "Z100A8A8A8A12A12A8aZ100A6A2Z32Z32A8A8Z155" |
Creates a new PosixHeader. A PosixHeader cannot be created unless the name, size, prefix, and mode are provided.