Fink::Checksum(3) Fink documentation Fink::Checksum(3)NAMEFink::Checksum - generate checksums of files
DESCRIPTIONFink::Checksum is a pluggable system for computing checksums of various
file types.
SYNOPSIS
use Fink::Checksum;
my $checksum = Fink::Checksum->new('MD5');
my $md5 = $checksum->get_checksum($filename);
### a module implementing a checksum type
# all checksum modules must reside under the Fink::Checksum namespace
package Fink::Checksum::ChecksumClass;
# all checksum modules must be subclasses of Fink::Checksum
use Fink::Checksum;
@ISA = qw(Fink::Checksum);
sub new {
my class = shift;
return bless {}, $class;
}
sub about {
my @about = ("ChecksumClass", "1.1", "Short Description", "dep-package");
return wantarray? @about : \@about;
}
sub get_checksum {
my $class = shift;
my $filename = shift;
my $output = `run-some-command`;
if ($output =~ /(some-matching-regex)/) {
return $1;
} else {
die "could not get checksum for $filename\n";
}
}
METHODSnew(PluginType) - get a new checksum object
Get a new checksum object, specifying the checksum method to use.
Checksum modules must provide a new() method that returns a blessed
ref for their object.
get_checksum($filename) - get the checksum for a file
Get the checksum for a given file, based on the Fink::Checksum::OBJ
object which represents a given algorithm.
This method cannot be used directly from a Fink::Checksum object,
it is designed to be overridden in the subclass.
$class->get_all_checksums($filename) - get all possible checksums for a
file
This class method returns a ref to a hash of algorithm=>checksum
pairs for all available algorithms for the given $filename.
$class->validate($filename, $checksum, [$algorithm]) - validate a file
Returns a boolean indicating whether the $checksum for file
$filename is correctw hen using $algorithm.
If $checksum is specified in the format used in the Source-Checksum
field (ie, the MD5(string) format), then $algorithm will be
detected automatically.
$class->parse_checksum($checksum, [$algorithm]) - tease apart different
syntaxes
This class method returns a (algorithm=>checksum) pair. If the
passed $checksum has the form of ALGORITHM(CHECKSUM), the ALGORITHM
and CHECKSUM components are returned separately. If the passed
$checksum is just a checksum string, $algorithm is used as the
algorithm. If the algorithm is not contained in the passed
$checksum and no $algorithm is passed, "MD5" is returned as the
algorithm.
list_plugins() - list the available checksum plugins
This method will list the available checksum plugins for
Fink::Checksum to use.
Fink 0.36.3.1 2013-12-30 Fink::Checksum(3)