Compress-Bzip2
view release on metacpan or search on metacpan
bzlib-src/bzip2.c view on Meta::CPAN
setExit(3);
exit(exitValue);
}
/*---------------------------------------------------*/
/*--- The main driver machinery ---*/
/*---------------------------------------------------*/
/* All rather crufty. The main problem is that input files
are stat()d multiple times before use. This should be
cleaned up.
*/
/*---------------------------------------------*/
static
void pad ( Char *s )
{
Int32 i;
if ( (Int32)strlen(s) >= longestFileName ) return;
for (i = 1; i <= longestFileName - (Int32)strlen(s); i++)
bzlib-src/bzip2.c view on Meta::CPAN
into fileMetaInfo before starting to compress / decompress it,
because doing it afterwards means we get the wrong access time.
To complicate matters, in compress() and decompress() below, the
sequence of tests preceding the call to saveInputFileMetaInfo()
involves calling fileExists(), which in turn establishes its result
by attempting to fopen() the file, and if successful, immediately
fclose()ing it again. So we have to assume that the fopen() call
does not cause the access time field to be updated.
Reading of the man page for stat() (man 2 stat) on RedHat 7.2 seems
to imply that merely doing open() will not affect the access time.
Therefore we merely need to hope that the C library only does
open() as a result of fopen(), and not any kind of read()-ahead
cleverness.
It sounds pretty fragile to me. Whether this carries across
robustly to arbitrary Unix-like platforms (or even works robustly
on this one, RedHat 7.2) is unknown to me. Nevertheless ...
*/
#if BZ_UNIX
lib/Compress/Bzip2.pm view on Meta::CPAN
print STDERR "Error: file $infile is not readable\n";
next;
}
@statbuf = stat _;
if ( !@statbuf ) {
print STDERR "Error: failed to stat $infile: '$!'\n";
next;
}
if ( !_check_stat( $infile, \@statbuf, $opts{f} ) ) {
print STDERR "Error: file $infile stat check fails: $bzerrno\n";
next;
}
}
my $outfile_exists;
if ( !$opts{c} ) {
undef $out;
if ( $opts{d} ) {
$outfile = $infile . '.bz2';
( run in 1.220 second using v1.01-cache-2.11-cpan-49f99fa48dc )