This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Typos in *.p[lm]
[perl5.git] / lib / Archive / Tar / Constant.pm
CommitLineData
39713df4
RGS
1package Archive::Tar::Constant;
2
3BEGIN {
4 require Exporter;
5 $VERSION= '0.02';
6 @ISA = qw[Exporter];
7 @EXPORT = qw[
8 FILE HARDLINK SYMLINK CHARDEV BLOCKDEV DIR FIFO SOCKET UNKNOWN
9 BUFFER HEAD READ_ONLY WRITE_ONLY UNPACK PACK TIME_OFFSET ZLIB
10 BLOCK_SIZE TAR_PAD TAR_END ON_UNIX BLOCK CAN_READLINK MAGIC
11 TAR_VERSION UNAME GNAME CAN_CHOWN MODE CHECK_SUM UID GID
12 GZIP_MAGIC_NUM MODE_READ LONGLINK LONGLINK_NAME PREFIX_LENGTH
13 LABEL NAME_LENGTH STRIP_MODE
14 ];
15
16 require Time::Local if $^O eq "MacOS";
17}
18
19use constant FILE => 0;
20use constant HARDLINK => 1;
21use constant SYMLINK => 2;
22use constant CHARDEV => 3;
23use constant BLOCKDEV => 4;
24use constant DIR => 5;
25use constant FIFO => 6;
26use constant SOCKET => 8;
27use constant UNKNOWN => 9;
28use constant LONGLINK => 'L';
29use constant LABEL => 'V';
30
31use constant BUFFER => 4096;
32use constant HEAD => 512;
33use constant BLOCK => 512;
34
35use constant BLOCK_SIZE => sub { my $n = int($_[0]/BLOCK); $n++ if $_[0] % BLOCK; $n * BLOCK };
36use constant TAR_PAD => sub { my $x = shift || return; return "\0" x (BLOCK - ($x % BLOCK) ) };
37use constant TAR_END => "\0" x BLOCK;
38
39use constant READ_ONLY => sub { shift() ? 'rb' : 'r' };
40use constant WRITE_ONLY => sub { $_[0] ? 'wb' . shift : 'w' };
41use constant MODE_READ => sub { $_[0] =~ /^r/ ? 1 : 0 };
42
3c4b39be 43# Pointless assignment to make -w shut up
39713df4
RGS
44my $getpwuid; $getpwuid = 'unknown' unless eval { my $f = getpwuid (0); };
45my $getgrgid; $getgrgid = 'unknown' unless eval { my $f = getgrgid (0); };
46use constant UNAME => sub { $getpwuid || scalar getpwuid( shift() ) };
47use constant GNAME => sub { $getgrgid || scalar getgrgid( shift() ) };
48use constant UID => $>;
49use constant GID => (split ' ', $) )[0];
50
51use constant MODE => do { 0666 & (0777 & ~umask) };
52use constant STRIP_MODE => sub { shift() & 0777 };
53use constant CHECK_SUM => " ";
54
55use constant UNPACK => 'A100 A8 A8 A8 A12 A12 A8 A1 A100 A6 A2 A32 A32 A8 A8 A155 x12';
56use constant PACK => 'a100 a8 a8 a8 a12 a12 A8 a1 a100 a6 a2 a32 a32 a8 a8 a155 x12';
57use constant NAME_LENGTH => 100;
58use constant PREFIX_LENGTH => 155;
59
60use constant TIME_OFFSET => ($^O eq "MacOS") ? Time::Local::timelocal(0,0,0,1,0,70) : 0;
61use constant MAGIC => "ustar";
62use constant TAR_VERSION => "00";
63use constant LONGLINK_NAME => '././@LongLink';
64
65use constant ZLIB => do { eval { require IO::Zlib }; $@ ? 0 : 1 };
66use constant GZIP_MAGIC_NUM => qr/^(?:\037\213|\037\235)/;
67
68use constant CAN_CHOWN => do { ($> == 0 and $^O ne "MacOS" and $^O ne "MSWin32") };
69use constant CAN_READLINK => ($^O ne 'MSWin32' and $^O !~ /RISC(?:[ _])?OS/i and $^O ne 'VMS');
70use constant ON_UNIX => ($^O ne 'MSWin32' and $^O ne 'MacOS' and $^O ne 'VMS');
71
721;