App-Fetchware
view release on metacpan or search on metacpan
lib/App/Fetchware.pm view on Meta::CPAN
my $digest;
if ($digest_type eq 'MD5') {
$digest = Digest::MD5->new();
} elsif ($digest_type eq 'SHA-1') {
$digest = Digest::SHA->new();
} else {
die <<EOD;
EOD
}
# Digest requires the filehandle to have binmode set.
binmode $package_fh;
my $calculated_digest;
eval {
# Add the file for digesting.
$digest->addfile($package_fh);
# Actually digest it.
$calculated_digest = $digest->hexdigest();
};
if ($@) {
die <<EOD;
lib/App/Fetchware/Util.pm view on Meta::CPAN
# Must convert the worthless $response->{content} variable into a real file
# on the filesystem. Note: start() should have cd()d us into a suitable
# tempdir.
my $path = $http_url;
$path =~ s!^http://!!;
# Determine filename from the $path.
my ($volume, $directories, $filename) = splitpath($path);
# If $filename is empty string, then its probably a index directory listing.
$filename ||= 'index.html';
###BUGALERT### Need binmode() on Windows???
###BUGALERT### Switch to safe_open()????
open(my $fh, '>', $filename) or die <<EOD;
App-Fetchware: run-time error. Fetchware failed to open a file necessary for
fetchware to store HTTP::Tiny's output. Os error [$!]. See perldoc
App::Fetchware.
EOD
# Write HTTP::Tiny's downloaded file to a real file on the filesystem.
print $fh $response->{content};
close $fh
or die <<EOS;
lib/Test/Fetchware.pm view on Meta::CPAN
open(my $package_fh, '<', $archive_to_md5)
or die <<EOD;
App-Fetchware: run-time error. Fetchware failed to open the file it downloaded
while trying to read it in order to check its MD5 sum. The file was
[$archive_to_md5]. OS error [$!]. See perldoc App::Fetchware.
EOD
my $digest = Digest::MD5->new();
# Digest requires the filehandle to have binmode set.
binmode $package_fh;
my $calculated_digest;
eval {
# Add the file for digesting.
$digest->addfile($package_fh);
# Actually digest it.
$calculated_digest = $digest->hexdigest();
};
if ($@) {
die <<EOD;
( run in 0.297 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )