[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[lintian] 01/02: L::Util: Add get_file_digest sub



This is an automated email from the git hooks/post-receive script.

nthykier pushed a commit to branch master
in repository lintian.

commit 9bbd8a52738eef64d3f302084ca53cfa22b7e235
Author: Niels Thykier <niels@thykier.net>
Date:   Thu Sep 1 18:04:43 2016 +0000

    L::Util: Add get_file_digest sub
    
    Signed-off-by: Niels Thykier <niels@thykier.net>
---
 lib/Lintian/Util.pm | 29 ++++++++++++++++++++++++-----
 1 file changed, 24 insertions(+), 5 deletions(-)

diff --git a/lib/Lintian/Util.pm b/lib/Lintian/Util.pm
index d5528c1..1776b66 100644
--- a/lib/Lintian/Util.pm
+++ b/lib/Lintian/Util.pm
@@ -59,6 +59,7 @@ BEGIN {
           get_deb_info
           get_dsc_info
           get_file_checksum
+          get_file_digest
           slurp_entire_file
           file_is_encoded_in_non_utf8
           is_string_utf8_encoded
@@ -786,19 +787,20 @@ sub drain_pipe {
     return 1;
 }
 
-=item get_file_checksum (ALGO, FILE)
+=item get_file_digest(ALGO, FILE)
 
-Returns a hexadecimal string of the message digest checksum generated
-by the algorithm ALGO on FILE.
+Creates an ALGO digest object that is seeded with the contents of
+FILE.  If you just want the hex digest, please use
+L</get_file_checksum(ALGO, FILE)> instead.
 
-ALGO can be 'md5' or shaX, where X is any number supported by
+ALGO can be 'md5' or shaX, where X is any numer supported by
 L<Digest::SHA> (e.g. 'sha256').
 
 This sub is a convenience wrapper around Digest::{MD5,SHA}.
 
 =cut
 
-sub get_file_checksum {
+sub get_file_digest {
     my ($alg, $file) = @_;
     open(my $fd, '<', $file);
     my $digest;
@@ -809,6 +811,23 @@ sub get_file_checksum {
     }
     $digest->addfile($fd);
     close($fd);
+    return $digest;
+}
+
+=item get_file_checksum(ALGO, FILE)
+
+Returns a hexadecimal string of the message digest checksum generated
+by the algorithm ALGO on FILE.
+
+ALGO can be 'md5' or shaX, where X is any number supported by
+L<Digest::SHA> (e.g. 'sha256').
+
+This sub is a convenience wrapper around Digest::{MD5,SHA}.
+
+=cut
+
+sub get_file_checksum {
+    my $digest = get_file_digest(@_);
     return $digest->hexdigest;
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git


Reply to: