This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update Archive-Tar to CPAN version 1.76
[perl5.git] / cpan / Archive-Tar / lib / Archive / Tar / Constant.pm
CommitLineData
39713df4
RGS
1package Archive::Tar::Constant;
2
3BEGIN {
4 require Exporter;
642eb381 5
89ae55b4 6 $VERSION = '1.76';
642eb381 7 @ISA = qw[Exporter];
39713df4
RGS
8
9 require Time::Local if $^O eq "MacOS";
10}
11
642eb381
SH
12use Package::Constants;
13@EXPORT = Package::Constants->list( __PACKAGE__ );
14
39713df4
RGS
15use constant FILE => 0;
16use constant HARDLINK => 1;
17use constant SYMLINK => 2;
18use constant CHARDEV => 3;
19use constant BLOCKDEV => 4;
20use constant DIR => 5;
21use constant FIFO => 6;
22use constant SOCKET => 8;
23use constant UNKNOWN => 9;
24use constant LONGLINK => 'L';
25use constant LABEL => 'V';
26
27use constant BUFFER => 4096;
28use constant HEAD => 512;
29use constant BLOCK => 512;
30
642eb381
SH
31use constant COMPRESS_GZIP => 9;
32use constant COMPRESS_BZIP => 'bzip2';
33
39713df4
RGS
34use constant BLOCK_SIZE => sub { my $n = int($_[0]/BLOCK); $n++ if $_[0] % BLOCK; $n * BLOCK };
35use constant TAR_PAD => sub { my $x = shift || return; return "\0" x (BLOCK - ($x % BLOCK) ) };
36use constant TAR_END => "\0" x BLOCK;
37
38use constant READ_ONLY => sub { shift() ? 'rb' : 'r' };
39use constant WRITE_ONLY => sub { $_[0] ? 'wb' . shift : 'w' };
40use constant MODE_READ => sub { $_[0] =~ /^r/ ? 1 : 0 };
41
3c4b39be 42# Pointless assignment to make -w shut up
39713df4
RGS
43my $getpwuid; $getpwuid = 'unknown' unless eval { my $f = getpwuid (0); };
44my $getgrgid; $getgrgid = 'unknown' unless eval { my $f = getgrgid (0); };
97a504ba
RGS
45use constant UNAME => sub { $getpwuid || scalar getpwuid( shift() ) || '' };
46use constant GNAME => sub { $getgrgid || scalar getgrgid( shift() ) || '' };
39713df4
RGS
47use constant UID => $>;
48use constant GID => (split ' ', $) )[0];
49
50use constant MODE => do { 0666 & (0777 & ~umask) };
51use constant STRIP_MODE => sub { shift() & 0777 };
52use constant CHECK_SUM => " ";
53
54use constant UNPACK => 'A100 A8 A8 A8 A12 A12 A8 A1 A100 A6 A2 A32 A32 A8 A8 A155 x12';
55use constant PACK => 'a100 a8 a8 a8 a12 a12 A8 a1 a100 a6 a2 a32 a32 a8 a8 a155 x12';
56use constant NAME_LENGTH => 100;
57use constant PREFIX_LENGTH => 155;
58
59use constant TIME_OFFSET => ($^O eq "MacOS") ? Time::Local::timelocal(0,0,0,1,0,70) : 0;
60use constant MAGIC => "ustar";
61use constant TAR_VERSION => "00";
62use constant LONGLINK_NAME => '././@LongLink';
642eb381 63use constant PAX_HEADER => 'pax_global_header';
39713df4 64
642eb381 65 ### allow ZLIB to be turned off using ENV: DEBUG only
81a5970e
RGS
66use constant ZLIB => do { !$ENV{'PERL5_AT_NO_ZLIB'} and
67 eval { require IO::Zlib };
642eb381
SH
68 $ENV{'PERL5_AT_NO_ZLIB'} || $@ ? 0 : 1
69 };
70
71 ### allow BZIP to be turned off using ENV: DEBUG only
72use constant BZIP => do { !$ENV{'PERL5_AT_NO_BZIP'} and
73 eval { require IO::Uncompress::Bunzip2;
74 require IO::Compress::Bzip2; };
75 $ENV{'PERL5_AT_NO_BZIP'} || $@ ? 0 : 1
76 };
77
39713df4 78use constant GZIP_MAGIC_NUM => qr/^(?:\037\213|\037\235)/;
642eb381 79use constant BZIP_MAGIC_NUM => qr/^BZh\d/;
39713df4 80
2610e7a4 81use constant CAN_CHOWN => sub { ($> == 0 and $^O ne "MacOS" and $^O ne "MSWin32") };
39713df4
RGS
82use constant CAN_READLINK => ($^O ne 'MSWin32' and $^O !~ /RISC(?:[ _])?OS/i and $^O ne 'VMS');
83use constant ON_UNIX => ($^O ne 'MSWin32' and $^O ne 'MacOS' and $^O ne 'VMS');
f5afd28d 84use constant ON_VMS => $^O eq 'VMS';
39713df4
RGS
85
861;