Add a function to calculate the MD5 sum of a file.

This commit is contained in:
Klaas Freitag 2013-11-06 16:13:39 +01:00
parent cd823524b6
commit 97f5bd840e

View file

@ -54,7 +54,7 @@ our $localDir;
@ISA = qw(Exporter);
@EXPORT = qw( initTesting createRemoteDir createLocalDir cleanup csync
assertLocalDirs assertLocalAndRemoteDir glob_put put_to_dir
putToDirLWP localDir remoteDir localCleanup createLocalFile
putToDirLWP localDir remoteDir localCleanup createLocalFile md5OfFile
remoteCleanup server initLocalDir initRemoteDir moveRemoteFile);
sub server
@ -466,6 +466,20 @@ sub createLocalFile( $$ )
return $md5->hexdigest;
}
sub md5OfFile( $ )
{
my ($file) = @_;
open FILE, "$file";
my $ctx = Digest::MD5->new;
$ctx->addfile (*FILE);
my $hash = $ctx->hexdigest;
close (FILE);
return $hash;
}
sub moveRemoteFile($$)
{
my ($from, $to) = @_;