Compare commits
No commits in common. "b5fdd9c0a5ec04d08f4330925d38abd6fe38dc7b" and "5b8d678b6b609a6205e8de645b218b4ad6782d5d" have entirely different histories.
b5fdd9c0a5
...
5b8d678b6b
5
Build.PL
5
Build.PL
@ -62,9 +62,8 @@ my $build = Module::Build->new(
|
|||||||
},
|
},
|
||||||
recommends => {
|
recommends => {
|
||||||
"File::MMagic" => 0,
|
"File::MMagic" => 0,
|
||||||
"IO::Compress::Gzip" => 0,
|
"Compress::Zlib" => 0,
|
||||||
"IO::Compress::Bzip2" => 2,
|
"Compress::Bzip2" => 2,
|
||||||
"IO::Compress::Xz" => 0,
|
|
||||||
"Term::ReadKey" => 0,
|
"Term::ReadKey" => 0,
|
||||||
},
|
},
|
||||||
build_requires => {
|
build_requires => {
|
||||||
|
8
Changes
8
Changes
@ -1,11 +1,7 @@
|
|||||||
arclog change log
|
arclog change log
|
||||||
|
|
||||||
2022-03-19 version 3.06
|
2022-03-19
|
||||||
1. Added support for the xz compression.
|
Added support for the xz compression.
|
||||||
2. Replaced Compress::Zlib with IO::Compress::Gzip and
|
|
||||||
IO::Uncompress::Gunzip.
|
|
||||||
2. Replaced Compress::Bzip2 with IO::Compress::Bzip2 and
|
|
||||||
IO::Uncompress::Bunzip2.
|
|
||||||
|
|
||||||
2020-02-06 version 3.05
|
2020-02-06 version 3.05
|
||||||
1. Replaced the messy GNU-styled, multi-lingual documents with a
|
1. Replaced the messy GNU-styled, multi-lingual documents with a
|
||||||
|
@ -52,9 +52,8 @@ EOT
|
|||||||
our (%OPT_PREREQ);
|
our (%OPT_PREREQ);
|
||||||
%OPT_PREREQ = (
|
%OPT_PREREQ = (
|
||||||
"File::MMagic" => 0,
|
"File::MMagic" => 0,
|
||||||
"IO::Compress::Gzip" => 0,
|
"Compress::Zlib" => 0,
|
||||||
"IO::Compress::Bzip2" => 2,
|
"Compress::Bzip2" => 2,
|
||||||
"IO::Compress::Xz" => 0,
|
|
||||||
"Term::ReadKey" => 0,
|
"Term::ReadKey" => 0,
|
||||||
);
|
);
|
||||||
delete $OPT_PREREQ{$_}
|
delete $OPT_PREREQ{$_}
|
||||||
|
76
README.md
76
README.md
@ -174,23 +174,22 @@ System Requirement
|
|||||||
the [GnuWin32] home page. Be sure to save it as `file.exe`
|
the [GnuWin32] home page. Be sure to save it as `file.exe`
|
||||||
somewhere in your `PATH`.
|
somewhere in your `PATH`.
|
||||||
|
|
||||||
* [IO::Compress::Gzip] and [IO::Uncompress::Gunzip]
|
* [Compress::Zlib]
|
||||||
|
|
||||||
They are used to support reading/writing the gzip compressed
|
This is used to support reading/writing the gzip compressed
|
||||||
files. It is only needed when gzip compressed files are
|
files. It is only needed when gzip compressed files are
|
||||||
encountered. If they are not available, `arclog` tries the
|
encountered. If it is not available, `arclog` tries the `gzip`
|
||||||
`gzip` executable instead. If that is not available, too,
|
executable instead. If that is not available, too, `arclog`
|
||||||
`arclog` fails. You should not worry about IO::Compress::Gzip
|
fails. You should not worry about Compress::Zlib since it comes
|
||||||
since it comes with Perl since version 5.9.3. If not, it is
|
with Perl since version 5.9.3. If not, it is contained in the
|
||||||
contained in the [IO-Compress] distribution. You can download
|
[IO-Compress] distribution. You can download and install it from
|
||||||
and install it from the CPAN archive, or install it with the
|
the CPAN archive, or install it with the CPAN shell:
|
||||||
CPAN shell:
|
|
||||||
|
|
||||||
cpan IO::Compress::Gzip
|
cpan Compress::Zlib
|
||||||
|
|
||||||
or with the CPANPLUS shell:
|
or with the CPANPLUS shell:
|
||||||
|
|
||||||
cpanp i IO::Compress::Gzip
|
cpanp i Compress::Zlib
|
||||||
|
|
||||||
For Debian/Ubuntu:
|
For Debian/Ubuntu:
|
||||||
|
|
||||||
@ -212,39 +211,38 @@ System Requirement
|
|||||||
[the gzip website]. Be sure to save it as `gzip.exe` somewhere
|
[the gzip website]. Be sure to save it as `gzip.exe` somewhere
|
||||||
in your `PATH`.
|
in your `PATH`.
|
||||||
|
|
||||||
* [IO::Compress::Bzip2] and [IO::Uncompress::Bunzip2]
|
* [Compress::Bzip2] version 2 or above.
|
||||||
|
|
||||||
They are used to support reading/writing the bzip2 compressed
|
This is used to support reading/writing the bzip2 compressed
|
||||||
files. They are only needed when bzip2 compressed files are
|
files. It is only needed when bzip2 compressed files are
|
||||||
encountered. If they are not available, `arclog` tries the
|
encountered. If it is not available, `arclog` tries the `bzip2`
|
||||||
`bzip2` executable instead. If that is not available, too,
|
executable instead. If that is not available, too, `arclog`
|
||||||
`arclog` fails. You should not worry about IO::Compress::Bzip2
|
fails. Notice that older versions before 2 does not work, since
|
||||||
since it comes with Perl since version 5.10.1. If not, it is
|
the file I/O compression was not implemented yet. You can
|
||||||
contained in the [IO-Compress] distribution. You can download
|
download and install Compress::Bzip2 from the CPAN archive, or
|
||||||
and install it from the CPAN archive, or install it with the
|
install it with the CPAN shell:
|
||||||
CPAN shell:
|
|
||||||
|
|
||||||
cpan IO::Compress::Bzip2
|
cpan Compress::Bzip2
|
||||||
|
|
||||||
or with the CPANPLUS shell:
|
or with the CPANPLUS shell:
|
||||||
|
|
||||||
cpanp i IO::Compress::Bzip2
|
cpanp i Compress::Bzip2
|
||||||
|
|
||||||
For Debian/Ubuntu:
|
For Debian/Ubuntu:
|
||||||
|
|
||||||
sudo apt install libio-compress-perl
|
sudo apt install libcompress-bzip2-perl
|
||||||
|
|
||||||
For Red Hat/Fedora/CentOS:
|
For Red Hat/Fedora/CentOS:
|
||||||
|
|
||||||
sudo yum install perl-IO-Compress
|
sudo yum install perl-Compress-Bzip2
|
||||||
|
|
||||||
For FreeBSD:
|
For FreeBSD:
|
||||||
|
|
||||||
ports install p5-IO-Compress
|
ports install p5-Compress-Bzip2
|
||||||
|
|
||||||
For ActivePerl:
|
For ActivePerl:
|
||||||
|
|
||||||
ppm install IO-Compress
|
ppm install Compress-Bzip2
|
||||||
|
|
||||||
The alternative `bzip2.exe` for MS-Windows can be obtained from
|
The alternative `bzip2.exe` for MS-Windows can be obtained from
|
||||||
[the bzip2 website]. Be sure to save it as `bzip2.exe` somewhere
|
[the bzip2 website]. Be sure to save it as `bzip2.exe` somewhere
|
||||||
@ -322,12 +320,10 @@ System Requirement
|
|||||||
[Date::Parse]: https://metacpan.org/pod/Date::Parse
|
[Date::Parse]: https://metacpan.org/pod/Date::Parse
|
||||||
[File::MMagic]: https://metacpan.org/pod/File::MMagic
|
[File::MMagic]: https://metacpan.org/pod/File::MMagic
|
||||||
[GnuWin32]: http://gnuwin32.sourceforge.net
|
[GnuWin32]: http://gnuwin32.sourceforge.net
|
||||||
[IO::Compress::Gzip]: https://metacpan.org/pod/IO::Compress::Gzip
|
[Compress::Zlib]: https://metacpan.org/pod/Compress::Zlib
|
||||||
[IO::Uncompress::Gunzip]: https://metacpan.org/pod/IO::Uncompress::Gunzip
|
|
||||||
[the gzip website]: https://www.gzip.org
|
[the gzip website]: https://www.gzip.org
|
||||||
[IO-Compress]: https://metacpan.org/dist/IO-Compress
|
[IO-Compress]: https://metacpan.org/dist/IO-Compress
|
||||||
[IO::Compress::Bzip2]: https://metacpan.org/pod/IO::Compress::Bzip2
|
[Compress::Bzip2]: https://metacpan.org/pod/Compress::Bzip2
|
||||||
[IO::Uncompress::Bunzip2]: https://metacpan.org/pod/IO::Uncompress::Bunzip2
|
|
||||||
[the bzip2 website]: http://www.bzip.org
|
[the bzip2 website]: http://www.bzip.org
|
||||||
[IO::Compress::Xz]: https://metacpan.org/pod/IO::Compress::Xz
|
[IO::Compress::Xz]: https://metacpan.org/pod/IO::Compress::Xz
|
||||||
[IO::Uncompress::UnXz]: https://metacpan.org/pod/IO::Uncompress::UnXz
|
[IO::Uncompress::UnXz]: https://metacpan.org/pod/IO::Uncompress::UnXz
|
||||||
@ -496,18 +492,18 @@ Options
|
|||||||
* `g`, `gzip`
|
* `g`, `gzip`
|
||||||
|
|
||||||
Compress with `gzip`. This is the default. `arclog` can use
|
Compress with `gzip`. This is the default. `arclog` can use
|
||||||
`IO::Compress::Gzip` to compress instead of calling `gzip`.
|
`Compress::Zlib` to compress instead of calling `gzip`. This can
|
||||||
This can be safer and faster for not calling foreign binaries.
|
be safer and faster for not calling foreign binaries. If
|
||||||
If `IO::Compress::Gzip` is not installed, it tries `gzip`
|
`Compress::Zlib` is not installed, it tries `gzip` instead. If
|
||||||
instead. If `gzip` is not available, either, it fails.
|
`gzip` is not available, either, it fails.
|
||||||
|
|
||||||
* `b`, `bzip2`
|
* `b`, `bzip2`
|
||||||
|
|
||||||
Compress with `bzip2`. `arclog` can use `IO::Compress::Bzip2`
|
Compress with `bzip2`. `arclog` can use `Compress::Bzip2` to
|
||||||
to compress instead of calling `bzip2`. This can be safer and
|
compress instead of calling `bzip2`. This can be safer and faster
|
||||||
faster for not calling foreign binaries. If
|
for not calling foreign binaries. If `Compress::Bzip2` is not
|
||||||
`IO::Compress::Bzip2` is not installed, it tries `bzip2`
|
installed, it tries `bzip2` instead. If `bzip2` is not available,
|
||||||
instead. If `bzip2` is not available, either, it fails.
|
either, it fails.
|
||||||
|
|
||||||
* `x`, `xz`
|
* `x`, `xz`
|
||||||
|
|
||||||
|
166
arclog
166
arclog
@ -54,7 +54,7 @@ sub rel2abs($;$);
|
|||||||
our ($THIS_FILE, $VERBOSE);
|
our ($THIS_FILE, $VERBOSE);
|
||||||
our ($VERSION);
|
our ($VERSION);
|
||||||
$THIS_FILE = basename($0);
|
$THIS_FILE = basename($0);
|
||||||
$VERSION = "3.06";
|
$VERSION = "3.05";
|
||||||
$VERBOSE = 1;
|
$VERBOSE = 1;
|
||||||
|
|
||||||
our (%CONF, @LOGFILES, $THIS_MONTH, $PROGRESS_BAR);
|
our (%CONF, @LOGFILES, $THIS_MONTH, $PROGRESS_BAR);
|
||||||
@ -824,6 +824,7 @@ sub check_type : method {
|
|||||||
|
|
||||||
# Check by file name suffix
|
# Check by file name suffix
|
||||||
# Check by file name suffix on empty files, too.
|
# Check by file name suffix on empty files, too.
|
||||||
|
# Compress::Bzip2 2 creates empty files that confuses further processing.
|
||||||
if (-z $FH || $MAGIC_METHOD eq MAGIC_SUFFIX) {
|
if (-z $FH || $MAGIC_METHOD eq MAGIC_SUFFIX) {
|
||||||
return TYPE_GZIP if $file =~ /\.gz$/;
|
return TYPE_GZIP if $file =~ /\.gz$/;
|
||||||
return TYPE_BZIP2 if $file =~ /\.bz2$/;
|
return TYPE_BZIP2 if $file =~ /\.bz2$/;
|
||||||
@ -1264,13 +1265,13 @@ sub check_gzip : method {
|
|||||||
# Checked before
|
# Checked before
|
||||||
return ref($GZIP_IO)->new if defined $GZIP_IO;
|
return ref($GZIP_IO)->new if defined $GZIP_IO;
|
||||||
|
|
||||||
# See whether IO::Compress::Gzip or gzip
|
# See whether Compress::Zlib or gzip
|
||||||
print STDERR "Checking gzip I/O handler to use ... " if $VERBOSE > 1;
|
print STDERR "Checking gzip I/O handler to use ... " if $VERBOSE > 1;
|
||||||
print STDERR "\n Checking IO::Compress::Gzip ... " if $VERBOSE > 2;
|
print STDERR "\n Checking Compress::Zlib ... " if $VERBOSE > 2;
|
||||||
# Check if we have IO::Compress::Gzip
|
# Check if we have Compress::Zlib
|
||||||
if (eval { require IO::Compress::Gzip; require IO::Uncompress::Gunzip; 1; }) {
|
if (eval { require Compress::Zlib; 1; }) {
|
||||||
print STDERR "OK\nfound " if $VERBOSE > 2;
|
print STDERR "OK\nfound " if $VERBOSE > 2;
|
||||||
print STDERR "IO::Compress::Gzip\n" if $VERBOSE > 1;
|
print STDERR "Compress::Zlib\n" if $VERBOSE > 1;
|
||||||
return ($GZIP_IO = _private::IO::Gzip::PM->new);
|
return ($GZIP_IO = _private::IO::Gzip::PM->new);
|
||||||
}
|
}
|
||||||
# Not found
|
# Not found
|
||||||
@ -1289,7 +1290,7 @@ sub check_gzip : method {
|
|||||||
print STDERR "no\n" if $VERBOSE > 2;
|
print STDERR "no\n" if $VERBOSE > 2;
|
||||||
|
|
||||||
print STDERR "not found\n" if $VERBOSE > 1;
|
print STDERR "not found\n" if $VERBOSE > 1;
|
||||||
die "$THIS_FILE: Necessary IO::Compress::Gzip or gzip not available.\n$SHORT_HELP\n";
|
die "$THIS_FILE: Necessary Compress::Zlib or gzip not available.\n$SHORT_HELP\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check for compression method of bzip2
|
# Check for compression method of bzip2
|
||||||
@ -1299,13 +1300,13 @@ sub check_bzip2 : method {
|
|||||||
# Checked before
|
# Checked before
|
||||||
return ref($BZIP2_IO)->new if defined $BZIP2_IO;
|
return ref($BZIP2_IO)->new if defined $BZIP2_IO;
|
||||||
|
|
||||||
# See whether IO::Compress::Bzip2 or bzip2
|
# See whether Compress::Bzip2 or bzip2
|
||||||
print STDERR "Checking bzip2 I/O handler to use ... " if $VERBOSE > 1;
|
print STDERR "Checking bzip2 I/O handler to use ... " if $VERBOSE > 1;
|
||||||
print STDERR "\n Checking IO::Compress::Bzip2 ... " if $VERBOSE > 2;
|
print STDERR "\n Checking Compress::Bzip2 ... " if $VERBOSE > 2;
|
||||||
# Check if we have IO::Compress::Bzip2
|
# Check if we have Compress::Bzip2
|
||||||
if (eval { require IO::Compress::Bzip2; require IO::Uncompress::Bunzip2; 1; }) {
|
if (eval { require Compress::Bzip2; import Compress::Bzip2 2.00; 1; }) {
|
||||||
print STDERR "OK\nfound " if $VERBOSE > 2;
|
print STDERR "OK\nfound " if $VERBOSE > 2;
|
||||||
print STDERR "IO::Compress::Bzip2\n" if $VERBOSE > 1;
|
print STDERR "Compress::Bzip2\n" if $VERBOSE > 1;
|
||||||
return ($BZIP2_IO = _private::IO::Bzip2::PM->new);
|
return ($BZIP2_IO = _private::IO::Bzip2::PM->new);
|
||||||
}
|
}
|
||||||
# Not found
|
# Not found
|
||||||
@ -1324,7 +1325,7 @@ sub check_bzip2 : method {
|
|||||||
print STDERR "no\n" if $VERBOSE > 2;
|
print STDERR "no\n" if $VERBOSE > 2;
|
||||||
|
|
||||||
print STDERR "not found\n" if $VERBOSE > 1;
|
print STDERR "not found\n" if $VERBOSE > 1;
|
||||||
die "$THIS_FILE: Necessary IO::Compress::Bzip2 or bzip2 not available.\n$SHORT_HELP\n";
|
die "$THIS_FILE: Necessary Compress::Bzip2 or bzip2 not available.\n$SHORT_HELP\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check for compression method of xz
|
# Check for compression method of xz
|
||||||
@ -1598,9 +1599,9 @@ sub open_read : method {
|
|||||||
print STDERR "done\n" if $VERBOSE > 2;
|
print STDERR "done\n" if $VERBOSE > 2;
|
||||||
}
|
}
|
||||||
($self->{"file"}, $self->{"FH"}) = ($file, $FH);
|
($self->{"file"}, $self->{"FH"}) = ($file, $FH);
|
||||||
print STDERR " Attaching file with IO::Uncompress::Gunzip ... " if $VERBOSE > 2;
|
import Compress::Zlib qw(gzopen);
|
||||||
$self->{"gz"} = IO::Uncompress::Gunzip->new($FH)
|
print STDERR " Attaching file with gzopen(..., \"rb\") ... " if $VERBOSE > 2;
|
||||||
or die "$THIS_FILE: $file: $IO::Uncompress::Gunzip::GunzipError";
|
$self->{"gz"} = gzopen($FH, "rb") or die "$THIS_FILE: $file: $!";
|
||||||
print STDERR "done\n" if $VERBOSE > 2;
|
print STDERR "done\n" if $VERBOSE > 2;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1619,9 +1620,9 @@ sub open_write : method {
|
|||||||
print STDERR "done\n" if $VERBOSE > 2;
|
print STDERR "done\n" if $VERBOSE > 2;
|
||||||
}
|
}
|
||||||
($self->{"file"}, $self->{"FH"}) = ($file, $FH);
|
($self->{"file"}, $self->{"FH"}) = ($file, $FH);
|
||||||
print STDERR " Attaching file with IO::Compress::Gzip ... " if $VERBOSE > 2;
|
import Compress::Zlib qw(gzopen);
|
||||||
$self->{"gz"} = IO::Compress::Gzip->new($FH)
|
print STDERR " Attaching file with gzopen(..., \"wb9\") ... " if $VERBOSE > 2;
|
||||||
or die "$THIS_FILE: $file: $IO::Compress::Gzip::GzipError";
|
$self->{"gz"} = gzopen($FH, "wb9") or die "$THIS_FILE: $file: $!";
|
||||||
print STDERR "done\n" if $VERBOSE > 2;
|
print STDERR "done\n" if $VERBOSE > 2;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1640,6 +1641,7 @@ sub open_append : method {
|
|||||||
print STDERR "done\n" if $VERBOSE > 2;
|
print STDERR "done\n" if $VERBOSE > 2;
|
||||||
}
|
}
|
||||||
($self->{"file"}, $self->{"FH"}) = ($file, $FH);
|
($self->{"file"}, $self->{"FH"}) = ($file, $FH);
|
||||||
|
import Compress::Zlib qw(gzopen);
|
||||||
|
|
||||||
# Save the original data if file has content so that file size is
|
# Save the original data if file has content so that file size is
|
||||||
# greater than 0. STDOUT is always of size 0.
|
# greater than 0. STDOUT is always of size 0.
|
||||||
@ -1660,20 +1662,18 @@ sub open_append : method {
|
|||||||
print STDERR "done\n" if $VERBOSE > 2;
|
print STDERR "done\n" if $VERBOSE > 2;
|
||||||
|
|
||||||
# Decompress the buffer and save to our file
|
# Decompress the buffer and save to our file
|
||||||
print STDERR " Attaching buffer with IO::Uncompress::Gunzip ... " if $VERBOSE > 2;
|
print STDERR " Attaching buffer with gzopen(..., \"rb\") ... " if $VERBOSE > 2;
|
||||||
$gzt = IO::Uncompress::Gunzip->new($FHT)
|
$gzt = gzopen($FHT, "rb") or die "$THIS_FILE: tempfile: $!";
|
||||||
or die "$THIS_FILE: tempfile: $IO::Uncompress::Gunzip::GunzipError";
|
|
||||||
print STDERR "done\n" if $VERBOSE > 2;
|
print STDERR "done\n" if $VERBOSE > 2;
|
||||||
print STDERR " Attaching file with IO::Compress::Gzip ... " if $VERBOSE > 2;
|
print STDERR " Attaching file with gzopen(..., \"wb9\") ... " if $VERBOSE > 2;
|
||||||
$gz = IO::Compress::Gzip->new($FH)
|
$gz = gzopen($FH, "wb9") or die "$THIS_FILE: $file: $!";
|
||||||
or die "$THIS_FILE: $file: $IO::Compress::Gzip::GzipError";
|
|
||||||
print STDERR "done\n" if $VERBOSE > 2;
|
print STDERR "done\n" if $VERBOSE > 2;
|
||||||
|
|
||||||
print STDERR " Reading old records back from the buffer ... " if $VERBOSE > 2;
|
print STDERR " Reading old records back from the buffer ... " if $VERBOSE > 2;
|
||||||
$count = 0;
|
$count = 0;
|
||||||
while (defined($_ = $gzt->getline)) {
|
while (($n = $gzt->gzreadline($_)) != 0) {
|
||||||
($gz->write($_) == length $_)
|
die "$THIS_FILE: tempfile: " . $gz->gzerror if $n == -1;
|
||||||
or die "$THIS_FILE: $file: $IO::Compress::Gzip::GzipError";
|
($gz->gzwrite($_) == $n) or die "$THIS_FILE: $file: " . $gz->gzerror;
|
||||||
$count++;
|
$count++;
|
||||||
}
|
}
|
||||||
close $FHT or die "$THIS_FILE: tempfile: $!";
|
close $FHT or die "$THIS_FILE: tempfile: $!";
|
||||||
@ -1681,9 +1681,8 @@ sub open_append : method {
|
|||||||
|
|
||||||
# A whole new file
|
# A whole new file
|
||||||
} else {
|
} else {
|
||||||
print STDERR " Attaching file with IO::Compress::Gzip ... " if $VERBOSE > 2;
|
print STDERR " Attaching file with gzopen(..., \"wb9\") ... " if $VERBOSE > 2;
|
||||||
$gz = IO::Compress::Gzip->new($FH)
|
$gz = gzopen($FH, "wb9") or die "$THIS_FILE: $file: $!";
|
||||||
or die "$THIS_FILE: $file: $IO::Compress::Gzip::GzipError";
|
|
||||||
print STDERR "done\n" if $VERBOSE > 2;
|
print STDERR "done\n" if $VERBOSE > 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1693,7 +1692,13 @@ sub open_append : method {
|
|||||||
|
|
||||||
# Read a line from the I/O stream
|
# Read a line from the I/O stream
|
||||||
sub readline : method {
|
sub readline : method {
|
||||||
return $_[0]->{"gz"}->getline();
|
local ($_, %_);
|
||||||
|
my ($self, $file, $gz, $n);
|
||||||
|
$self = $_[0];
|
||||||
|
($file, $gz) = ($self->{"file"}, $self->{"gz"});
|
||||||
|
(($n = $gz->gzreadline($_)) != -1) or die "$THIS_FILE: $file: " . $gz->gzerror;
|
||||||
|
return undef if $n == 0;
|
||||||
|
return $_;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Output data to the I/O stream
|
# Output data to the I/O stream
|
||||||
@ -1702,7 +1707,7 @@ sub write : method {
|
|||||||
my ($self, $file, $gz);
|
my ($self, $file, $gz);
|
||||||
($self, $_) = @_;
|
($self, $_) = @_;
|
||||||
($file, $gz) = ($self->{"file"}, $self->{"gz"});
|
($file, $gz) = ($self->{"file"}, $self->{"gz"});
|
||||||
($gz->write($_) == length $_) or die "$THIS_FILE: $file: $IO::Compress::Gzip::GzipError";
|
($gz->gzwrite($_) == length $_) or die "$THIS_FILE: $file: " . $gz->gzerror;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1724,16 +1729,15 @@ sub close : method {
|
|||||||
|
|
||||||
# Create empty compressed content
|
# Create empty compressed content
|
||||||
print STDERR " Applying empty compressed content ... " if $VERBOSE > 2;
|
print STDERR " Applying empty compressed content ... " if $VERBOSE > 2;
|
||||||
$_ = IO::Compress::Gzip->new($FH, Append => 0)
|
$_ = gzopen($FH, "wb9") or die "$THIS_FILE: $file: $!";
|
||||||
or die "$THIS_FILE: $file: $IO::Compress::Gzip::GzipError";
|
$_->gzclose and die "$THIS_FILE: $file: " . $_->gzerror;
|
||||||
$_->close or die "$THIS_FILE: $file: $IO::Compress::Gzip::GzipError";
|
|
||||||
undef $_;
|
undef $_;
|
||||||
undef $gz;
|
undef $gz;
|
||||||
print STDERR "done\n" if $VERBOSE > 2;
|
print STDERR "done\n" if $VERBOSE > 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined $gz) {
|
if (defined $gz) {
|
||||||
$gz->close or die "$THIS_FILE: $file: $IO::Compress::Gzip::GzipError";
|
$gz->gzclose and die "$THIS_FILE: $file: " . $gz->gzerror;
|
||||||
}
|
}
|
||||||
CORE::close $self->{"FH"} if $self->{"FH"}->opened;
|
CORE::close $self->{"FH"} if $self->{"FH"}->opened;
|
||||||
delete $self->{"gz"};
|
delete $self->{"gz"};
|
||||||
@ -2055,9 +2059,9 @@ sub open_read : method {
|
|||||||
print STDERR "done\n" if $VERBOSE > 2;
|
print STDERR "done\n" if $VERBOSE > 2;
|
||||||
}
|
}
|
||||||
($self->{"file"}, $self->{"FH"}) = ($file, $FH);
|
($self->{"file"}, $self->{"FH"}) = ($file, $FH);
|
||||||
print STDERR " Attaching file with IO::Uncompress::Bunzip2 ... " if $VERBOSE > 2;
|
import Compress::Bzip2 qw(bzopen);
|
||||||
$self->{"bz"} = IO::Uncompress::Bunzip2->new($FH)
|
print STDERR " Attaching file with bzopen(..., \"rb\") ... " if $VERBOSE > 2;
|
||||||
or die "$THIS_FILE: $file: $IO::Uncompress::Bunzip2::Bunzip2Error";
|
$self->{"bz"} = bzopen($FH, "rb") or die "$THIS_FILE: $file: $!";
|
||||||
print STDERR "done\n" if $VERBOSE > 2;
|
print STDERR "done\n" if $VERBOSE > 2;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2076,9 +2080,9 @@ sub open_write : method {
|
|||||||
print STDERR "done\n" if $VERBOSE > 2;
|
print STDERR "done\n" if $VERBOSE > 2;
|
||||||
}
|
}
|
||||||
($self->{"file"}, $self->{"FH"}) = ($file, $FH);
|
($self->{"file"}, $self->{"FH"}) = ($file, $FH);
|
||||||
print STDERR " Attaching file with IO::Compress::Bzip2 ... " if $VERBOSE > 2;
|
import Compress::Bzip2 qw(bzopen);
|
||||||
$self->{"bz"} = IO::Compress::Bzip2->new($FH)
|
print STDERR " Attaching file with bzopen(..., \"wb9\") ... " if $VERBOSE > 2;
|
||||||
or die "$THIS_FILE: $file: $IO::Compress::Bzip2::Bzip2Error";
|
$self->{"bz"} = bzopen($FH, "wb9") or die "$THIS_FILE: $file: $!";
|
||||||
print STDERR "done\n" if $VERBOSE > 2;
|
print STDERR "done\n" if $VERBOSE > 2;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2097,6 +2101,7 @@ sub open_append : method {
|
|||||||
print STDERR "done\n" if $VERBOSE > 2;
|
print STDERR "done\n" if $VERBOSE > 2;
|
||||||
}
|
}
|
||||||
($self->{"file"}, $self->{"FH"}) = ($file, $FH);
|
($self->{"file"}, $self->{"FH"}) = ($file, $FH);
|
||||||
|
import Compress::Bzip2 qw(bzopen);
|
||||||
|
|
||||||
# Save the original data if file has content so that file size is
|
# Save the original data if file has content so that file size is
|
||||||
# greater than 0. STDOUT is always of size 0.
|
# greater than 0. STDOUT is always of size 0.
|
||||||
@ -2117,20 +2122,19 @@ sub open_append : method {
|
|||||||
print STDERR "done\n" if $VERBOSE > 2;
|
print STDERR "done\n" if $VERBOSE > 2;
|
||||||
|
|
||||||
# Decompress the buffer and save to our file
|
# Decompress the buffer and save to our file
|
||||||
print STDERR " Attaching buffer with IO::Uncompress::Bunzip2 ... " if $VERBOSE > 2;
|
print STDERR " Attaching buffer with bzopen(..., \"rb\") ... " if $VERBOSE > 2;
|
||||||
$bzt = IO::Uncompress::Bunzip2->new($FHT)
|
$bzt = bzopen($FHT, "rb") or die "$THIS_FILE: tempfile: $!";
|
||||||
or die "$THIS_FILE: $file: $IO::Uncompress::Bunzip2::Bunzip2Error";
|
|
||||||
print STDERR "done\n" if $VERBOSE > 2;
|
print STDERR "done\n" if $VERBOSE > 2;
|
||||||
print STDERR " Attaching file with IO::Compress::Bzip2 ... " if $VERBOSE > 2;
|
print STDERR " Attaching file with bzopen(..., \"wb9\") ... " if $VERBOSE > 2;
|
||||||
$bz = IO::Compress::Bzip2->new($FH)
|
$bz = bzopen($FH, "wb9") or die "$THIS_FILE: $file: $!";
|
||||||
or die "$THIS_FILE: $file: $IO::Compress::Bzip2::Bzip2Error";
|
|
||||||
print STDERR "done\n" if $VERBOSE > 2;
|
print STDERR "done\n" if $VERBOSE > 2;
|
||||||
|
|
||||||
print STDERR " Reading old records back from the buffer ... " if $VERBOSE > 2;
|
print STDERR " Reading old records back from the buffer ... " if $VERBOSE > 2;
|
||||||
$count = 0;
|
$count = 0;
|
||||||
while (defined($_ = $bzt->getline)) {
|
while (($n = $bzt->bzreadline($_)) != 0) {
|
||||||
($bz->write($_) == length $_)
|
die "$THIS_FILE: tempfile: " . $bz->bzerror if $n == -1;
|
||||||
or die "$THIS_FILE: $file: $IO::Compress::Bzip2::Bzip2Error";
|
($bz->bzwrite($_, length $_) == length $_)
|
||||||
|
or die "$THIS_FILE: $file: " . $bz->bzerror;
|
||||||
$count++;
|
$count++;
|
||||||
}
|
}
|
||||||
close $FHT or die "$THIS_FILE: tempfile: $!";
|
close $FHT or die "$THIS_FILE: tempfile: $!";
|
||||||
@ -2138,9 +2142,8 @@ sub open_append : method {
|
|||||||
|
|
||||||
# A whole new file
|
# A whole new file
|
||||||
} else {
|
} else {
|
||||||
print STDERR " Attaching file with IO::Compress::Bzip2 ... " if $VERBOSE > 2;
|
print STDERR " Attaching file with bzopen(..., \"wb9\") ... " if $VERBOSE > 2;
|
||||||
$bz = IO::Compress::Bzip2->new($FH)
|
$bz = bzopen($FH, "wb9") or die "$THIS_FILE: $file: $!";
|
||||||
or die "$THIS_FILE: $file: $IO::Compress::Bzip2::Bzip2Error";
|
|
||||||
print STDERR "done\n" if $VERBOSE > 2;
|
print STDERR "done\n" if $VERBOSE > 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2150,7 +2153,13 @@ sub open_append : method {
|
|||||||
|
|
||||||
# Read a line from the I/O stream
|
# Read a line from the I/O stream
|
||||||
sub readline : method {
|
sub readline : method {
|
||||||
return $_[0]->{"bz"}->getline();
|
local ($_, %_);
|
||||||
|
my ($self, $file, $bz, $n);
|
||||||
|
$self = $_[0];
|
||||||
|
($file, $bz) = ($self->{"file"}, $self->{"bz"});
|
||||||
|
(($n = $bz->bzreadline($_)) != -1) or die "$THIS_FILE: $file: " . $bz->bzerror;
|
||||||
|
return undef if $n == 0;
|
||||||
|
return $_;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Output data to the I/O stream
|
# Output data to the I/O stream
|
||||||
@ -2159,7 +2168,8 @@ sub write : method {
|
|||||||
my ($self, $file, $bz);
|
my ($self, $file, $bz);
|
||||||
($self, $_) = @_;
|
($self, $_) = @_;
|
||||||
($file, $bz) = ($self->{"file"}, $self->{"bz"});
|
($file, $bz) = ($self->{"file"}, $self->{"bz"});
|
||||||
($bz->write($_) == length $_) or die "$THIS_FILE: $file: $IO::Compress::Xz::XzError";
|
($bz->bzwrite($_, length $_) == length $_)
|
||||||
|
or die "$THIS_FILE: $file: " . $bz->bzerror;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2181,16 +2191,15 @@ sub close : method {
|
|||||||
|
|
||||||
# Create empty compressed content
|
# Create empty compressed content
|
||||||
print STDERR " Applying empty compressed content ... " if $VERBOSE > 2;
|
print STDERR " Applying empty compressed content ... " if $VERBOSE > 2;
|
||||||
$_ = IO::Compress::Bzip2->new($FH)
|
$_ = bzopen($FH, "wb9") or die "$THIS_FILE: $file: $!";
|
||||||
or die "$THIS_FILE: $file: $IO::Compress::Bzip2::Bzip2Error";
|
$_->bzclose and die "$THIS_FILE: $file: " . $_->bzerror;
|
||||||
$_->close or die "$THIS_FILE: $file: $IO::Compress::Bzip2::Bzip2Error";
|
|
||||||
undef $_;
|
undef $_;
|
||||||
undef $bz;
|
undef $bz;
|
||||||
print STDERR "done\n" if $VERBOSE > 2;
|
print STDERR "done\n" if $VERBOSE > 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined $bz) {
|
if (defined $bz) {
|
||||||
$bz->close or die "$THIS_FILE: $file: $IO::Compress::Bzip2::Bzip2Error";
|
$bz->bzclose and die "$THIS_FILE: $file: " . $bz->bzerror;
|
||||||
}
|
}
|
||||||
CORE::close $self->{"FH"} if $self->{"FH"}->opened;
|
CORE::close $self->{"FH"} if $self->{"FH"}->opened;
|
||||||
delete $self->{"bz"};
|
delete $self->{"bz"};
|
||||||
@ -2648,7 +2657,7 @@ sub close : method {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (defined $xz) {
|
if (defined $xz) {
|
||||||
$xz->close or die "$THIS_FILE: $file: $IO::Compress::Xz::XzError";
|
$xz->close or die "$THIS_FILE: $file: $IO::Compress::Xz::XzError!";
|
||||||
}
|
}
|
||||||
CORE::close $self->{"FH"} if $self->{"FH"}->opened;
|
CORE::close $self->{"FH"} if $self->{"FH"}->opened;
|
||||||
delete $self->{"xz"};
|
delete $self->{"xz"};
|
||||||
@ -3192,22 +3201,20 @@ them.) The following compression methods are supported:
|
|||||||
=item g, gzip
|
=item g, gzip
|
||||||
|
|
||||||
Compress with L<gzip(1)|gzip/1>. This is the default. F<arclog>
|
Compress with L<gzip(1)|gzip/1>. This is the default. F<arclog>
|
||||||
can use L<IO::Compress::Gzip(3)|IO::Compress::Gzip/3> to compress
|
can use L<Compress::Zlib(3)|Compress::Zlib/3> to compress instead of
|
||||||
instead of calling L<gzip(1)|gzip/1>. This can be safer and faster
|
calling L<gzip(1)|gzip/1>. This can be safer and faster for not
|
||||||
for not calling foreign binaries. if
|
calling foreign binaries. if L<Compress::Zlib(3)|Compress::Zlib/3>
|
||||||
L<IO::Compress::Gzip(3)|IO::Compress::Gzip/3> is not installed, it
|
is not installed, it tries L<gzip(1)|gzip/1> instead. If
|
||||||
tries L<gzip(1)|gzip/1> instead. If L<gzip(1)|gzip/1> is not
|
L<gzip(1)|gzip/1> is not available, either, it fails.
|
||||||
available, either, it fails.
|
|
||||||
|
|
||||||
=item b, bzip2
|
=item b, bzip2
|
||||||
|
|
||||||
Compress with L<bzip2(1)|bzip2/1>. F<arclog> can use
|
Compress with L<bzip2(1)|bzip2/1>. F<arclog> can use
|
||||||
L<IO::Compress::Bzip2(3)|IO::Compress::Bzip2/3> to compress
|
L<Compress::Bzip2(3)|Compress::Bzip2/3> to compress instead of
|
||||||
instead of calling L<bzip2(1)|bzip2/1>. This can be safer and faster
|
calling L<bzip2(1)|bzip2/1>. This can be safer and faster for not
|
||||||
for not calling foreign binaries. If
|
calling foreign binaries. If L<Compress::Bzip2(3)|Compress::Bzip2/3>
|
||||||
L<IO::Compress::Bzip2(3)|IO::Compress::Bzip2/3> is not installed, it
|
is not installed, it will try to use L<bzip2(1)|bzip2/1> instead. If
|
||||||
will try to use L<bzip2(1)|bzip2/1> instead. If L<bzip2(1)|bzip2/1>
|
L<bzip2(1)|bzip2/1> is not available, either, it fails.
|
||||||
is not available, either, it fails.
|
|
||||||
|
|
||||||
=item x, xz
|
=item x, xz
|
||||||
|
|
||||||
@ -3370,12 +3377,11 @@ messages.
|
|||||||
|
|
||||||
=head1 SEE ALSO
|
=head1 SEE ALSO
|
||||||
|
|
||||||
L<gzip(1)|gzip/1>, L<IO::Compress::Gzip(3)|IO::Compress::Gzip/3>,
|
L<gzip(1)|gzip/1>, L<bzip2(1)|bzip2/1>, L<xz(1)|xz/1>,
|
||||||
L<IO::Uncompress::Gunzip(3)|IO::Uncompress::Gunzip/3>,
|
L<Compress::Zlib(3)|Compress::Zlib/3>, L<syslog(1)|syslog/1>,
|
||||||
L<bzip2(1)|bzip2/1>, L<IO::Compress::Bzip2(3)|IO::Compress::Bzip2/3>,
|
L<Compress::Bzip2(3)|Compress::Bzip2/3>,
|
||||||
L<IO::Uncompress::Bunzip2(3)|IO::Uncompress::Bunzip2/3>,
|
L<IO::Compress::Xz(3)|IO::Compress::Xz/3>,
|
||||||
L<xz(1)|xz/1>, L<IO::Compress::Xz(3)|IO::Compress::Xz/3>,
|
|
||||||
L<IO::Uncompress::UnXz(3)|IO::Uncompress::UnXz/3>,
|
L<IO::Uncompress::UnXz(3)|IO::Uncompress::UnXz/3>,
|
||||||
L<syslog(1)|syslog/1>, L<syslog(2)|syslog/2>
|
L<syslog(2)|syslog/2>
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
113
t/_helper.pm
113
t/_helper.pm
@ -227,14 +227,22 @@ sub read_file($) {
|
|||||||
|
|
||||||
# a gzip compressed file
|
# a gzip compressed file
|
||||||
if ($file =~ /\.gz$/) {
|
if ($file =~ /\.gz$/) {
|
||||||
# IO::Uncompress::Gunzip
|
# Compress::Zlib
|
||||||
if (eval { require IO::Uncompress::Gunzip; 1; }) {
|
if (eval { require Compress::Zlib;
|
||||||
my $gz;
|
Compress::Zlib->import(qw(gzopen));
|
||||||
|
1; }) {
|
||||||
|
use Compress::Zlib qw(gzopen);
|
||||||
|
my ($FH, $gz);
|
||||||
$content = "";
|
$content = "";
|
||||||
$gz = IO::Uncompress::Gunzip->new($file)
|
open $FH, $file or die this_file . ": $file: $!";
|
||||||
or die this_file . ": $file: $IO::Uncompress::Gunzip::GunzipError";
|
$gz = gzopen($FH, "rb") or die this_file . ": $file: $!";
|
||||||
$content = join "", <$gz>;
|
while (1) {
|
||||||
$gz->close or die this_file . ": $file: $IO::Uncompress::Gunzip::GunzipError";
|
($gz->gzread($_, 10240) != -1)
|
||||||
|
or die this_file . ": $file: " . $gz->gzerror;
|
||||||
|
$content .= $_;
|
||||||
|
last if length $_ < 10240;
|
||||||
|
}
|
||||||
|
$gz->gzclose and die this_file . ": $file: " . $gz->gzerror;
|
||||||
return $content;
|
return $content;
|
||||||
|
|
||||||
# gzip executable
|
# gzip executable
|
||||||
@ -250,14 +258,22 @@ sub read_file($) {
|
|||||||
|
|
||||||
# a bzip compressed file
|
# a bzip compressed file
|
||||||
} elsif ($file =~ /\.bz2$/) {
|
} elsif ($file =~ /\.bz2$/) {
|
||||||
# IO::Uncompress::Bunzip2
|
# Compress::Bzip2
|
||||||
if (eval { require IO::Uncompress::Bunzip2; 1; }) {
|
if (eval { require Compress::Bzip2;
|
||||||
my $bz;
|
Compress::Bzip2->import(2.00);
|
||||||
|
Compress::Bzip2->import(qw(bzopen));
|
||||||
|
1; }) {
|
||||||
|
my ($FH, $bz);
|
||||||
$content = "";
|
$content = "";
|
||||||
$bz = IO::Uncompress::Bunzip2->new($file)
|
open $FH, $file or die this_file . ": $file: $!";
|
||||||
or die this_file . ": $file: $IO::Uncompress::Bunzip2::Bunzip2Error";
|
$bz = bzopen($FH, "rb") or die this_file . ": $file: $!";
|
||||||
$content = join "", <$bz>;
|
while (1) {
|
||||||
$bz->close or die this_file . ": $file: $IO::Uncompress::Bunzip2::Bunzip2Error";
|
($bz->bzread($_, 10240) != -1)
|
||||||
|
or die this_file . ": $file: " . $bz->bzerror;
|
||||||
|
$content .= $_;
|
||||||
|
last if length $_ < 10240;
|
||||||
|
}
|
||||||
|
$bz->bzclose and die this_file . ": $file: " . $bz->bzerror;
|
||||||
return $content;
|
return $content;
|
||||||
|
|
||||||
# bzip2 executable
|
# bzip2 executable
|
||||||
@ -272,14 +288,21 @@ sub read_file($) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# an xz compressed file
|
# an xz compressed file
|
||||||
} elsif ($file =~ /\.xz$/) {
|
} elsif ($file =~ /\.xz/) {
|
||||||
# IO::Uncompress::UnXz
|
# IO::Uncompress::UnXz
|
||||||
if (eval { require IO::Uncompress::UnXz; 1; }) {
|
if (eval { require IO::Uncompress::UnXz; 1; }) {
|
||||||
my $xz;
|
my ($FH, $xz);
|
||||||
$content = "";
|
$content = "";
|
||||||
$xz = IO::Uncompress::UnXz->new($file)
|
open $FH, $file or die this_file . ": $file: $!";
|
||||||
|
|
||||||
|
$xz = IO::Uncompress::UnXz->new($FH)
|
||||||
or die this_file . ": $file: $IO::Uncompress::UnXz::UnXzError";
|
or die this_file . ": $file: $IO::Uncompress::UnXz::UnXzError";
|
||||||
$content = join "", <$xz>;
|
while (1) {
|
||||||
|
($xz->read($_, 10240) != -1)
|
||||||
|
or die this_file . ": $file: $IO::Uncompress::UnXz::UnXzError";
|
||||||
|
$content .= $_;
|
||||||
|
last if length $_ < 10240;
|
||||||
|
}
|
||||||
$xz->close or die this_file . ": $file: $IO::Uncompress::UnXz::UnXzError";
|
$xz->close or die this_file . ": $file: $IO::Uncompress::UnXz::UnXzError";
|
||||||
return $content;
|
return $content;
|
||||||
|
|
||||||
@ -330,14 +353,16 @@ sub write_file($$) {
|
|||||||
|
|
||||||
# a gzip compressed file
|
# a gzip compressed file
|
||||||
if ($file =~ /\.gz$/) {
|
if ($file =~ /\.gz$/) {
|
||||||
# IO::Compress::Gzip
|
# Compress::Zlib
|
||||||
if (eval { require IO::Compress::Gzip; 1; }) {
|
if (eval { require Compress::Zlib;
|
||||||
my $gz;
|
Compress::Zlib->import(qw(gzopen));
|
||||||
$gz = IO::Compress::Gzip->new($file)
|
1; }) {
|
||||||
or die this_file . ": $file: $IO::Compress::Gzip::GzipError";
|
my ($FH, $gz);
|
||||||
($gz->write($content) == length $content)
|
open $FH, ">$file" or die this_file . ": $file: $!";
|
||||||
or die this_file . ": $file: $IO::Compress::Gzip::GzipError";
|
$gz = gzopen($FH, "wb9") or die this_file . ": $file: $!";
|
||||||
$gz->close or die this_file . ": $file: $IO::Compress::Gzip::GzipError";
|
($gz->gzwrite($content) == length $content)
|
||||||
|
or die this_file . ": $file: " . $gz->gzerror;
|
||||||
|
$gz->gzclose and die this_file . ": $file: " . $gz->gzerror;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
# gzip executable
|
# gzip executable
|
||||||
@ -353,14 +378,17 @@ sub write_file($$) {
|
|||||||
|
|
||||||
# a bzip compressed file
|
# a bzip compressed file
|
||||||
} elsif ($file =~ /\.bz2$/) {
|
} elsif ($file =~ /\.bz2$/) {
|
||||||
# IO::Compress::Bzip2
|
# Compress::Bzip2
|
||||||
if (eval { require IO::Compress::Bzip2; 1; }) {
|
if (eval { require Compress::Bzip2;
|
||||||
my $bz;
|
Compress::Bzip2->import(2.00);
|
||||||
$bz = IO::Compress::Bzip2->new($file)
|
Compress::Bzip2->import(qw(bzopen));
|
||||||
or die this_file . ": $file: $IO::Compress::Bzip2::Bzip2Error";
|
1; }) {
|
||||||
($bz->write($content) == length $content)
|
my ($FH, $bz);
|
||||||
or die this_file . ": $file: $IO::Compress::Bzip2::Bzip2Error";
|
open $FH, ">$file" or die this_file . ": $file: $!";
|
||||||
$bz->close or die this_file . ": $file: $IO::Compress::Bzip2::Bzip2Error";
|
$bz = bzopen($FH, "wb9") or die this_file . ": $file: $!";
|
||||||
|
($bz->bzwrite($content, length $content) == length $content)
|
||||||
|
or die this_file . ": $file: " . $bz->bzerror;
|
||||||
|
$bz->bzclose and die this_file . ": $file: " . $bz->bzerror;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
# bzip2 executable
|
# bzip2 executable
|
||||||
@ -375,13 +403,14 @@ sub write_file($$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# an xz compressed file
|
# an xz compressed file
|
||||||
} elsif ($file =~ /\.xz$/) {
|
} elsif ($file =~ /\.xz/) {
|
||||||
# IO::Compress::Xz
|
# IO::Compress::Xz
|
||||||
if (eval { require IO::Compress::Xz; 1; }) {
|
if (eval { require IO::Compress::Xz; 1; }) {
|
||||||
my $xz;
|
my ($FH, $xz);
|
||||||
$xz = IO::Compress::Xz->new($file)
|
open $FH, ">$file" or die this_file . ": $file: $!";
|
||||||
|
$xz = IO::Compress::Xz->new($FH)
|
||||||
or die this_file . ": $file: $IO::Compress::Xz::XzError";
|
or die this_file . ": $file: $IO::Compress::Xz::XzError";
|
||||||
($xz->write($content) == length $content)
|
($xz->write($content, length $content) == length $content)
|
||||||
or die this_file . ": $file: $IO::Compress::Xz::XzError";
|
or die this_file . ": $file: $IO::Compress::Xz::XzError";
|
||||||
$xz->close or die this_file . ": $file: $IO::Compress::Xz::XzError";
|
$xz->close or die this_file . ": $file: $IO::Compress::Xz::XzError";
|
||||||
return;
|
return;
|
||||||
@ -572,18 +601,18 @@ sub has_no_file() {
|
|||||||
|
|
||||||
# If we have gzip support somewhere
|
# If we have gzip support somewhere
|
||||||
sub has_no_gzip() {
|
sub has_no_gzip() {
|
||||||
$HAS_NO_GZIP = eval { require IO::Compress::Gzip; require IO::Uncompress::Gunzip; 1; }
|
$HAS_NO_GZIP = eval { require Compress::Zlib; 1; }
|
||||||
|| defined where_is "gzip"?
|
|| defined where_is "gzip"?
|
||||||
0: "IO::Compress::Gzip or gzip executable not available"
|
0: "Compress::Zlib or gzip executable not available"
|
||||||
if !defined $HAS_NO_GZIP;
|
if !defined $HAS_NO_GZIP;
|
||||||
return $HAS_NO_GZIP;
|
return $HAS_NO_GZIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
# If we have bzip2 support somewhere
|
# If we have bzip2 support somewhere
|
||||||
sub has_no_bzip2() {
|
sub has_no_bzip2() {
|
||||||
$HAS_NO_BZIP2 = eval { require IO::Compress::Bzip2; require IO::Uncompress::Bunzip2; 1; }
|
$HAS_NO_BZIP2 = eval { require Compress::Bzip2; Compress::Bzip2->import(2.00); 1; }
|
||||||
|| defined where_is "bzip2"?
|
|| defined where_is "bzip2"?
|
||||||
0: "IO::Compress::Bzip2 v2 or bzip2 executable not available"
|
0: "Compress::Bzip2 v2 or bzip2 executable not available"
|
||||||
if !defined $HAS_NO_BZIP2;
|
if !defined $HAS_NO_BZIP2;
|
||||||
return $HAS_NO_BZIP2;
|
return $HAS_NO_BZIP2;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user