Crypt-Rhash
view release on metacpan or search on metacpan
858687888990919293949596979899100101102103104105106107108109110111112# destructor
sub
DESTROY($)
{
my
$self
=
shift
;
# the 'if' added as workaround for perl 'global destruction' bug
# ($self->{context} can disappear on global destruction)
rhash_free(
$self
->{context})
if
$self
->{context};
}
sub
update($$)
{
my
$self
=
shift
;
my
$message
=
shift
;
rhash_update(
$self
->{context},
$message
);
return
$self
;
}
sub
update_fd($$;$$)
{
my
(
$self
,
$fd
,
$start
,
$size
) =
@_
;
my
$res
= 0;
my
$num
= 0;
binmode
(
$fd
);
if
(
defined
(
$start
)) {
seek
(
$fd
,
scalar
(
$start
), 0) or
return
undef
;
}
122123124125126127128129130131132133134135136137138139140141142
}
else
{
while
( (
$res
=
read
(
$fd
,
$data
, 8192)) ) {
rhash_update(
$self
->{context},
$data
);
$num
+=
$res
;
}
}
return
(
defined
(
$res
) ?
$num
:
undef
);
# return undef on read error
}
sub
update_file($$;$$)
{
my
(
$self
,
$file
,
$start
,
$size
) =
@_
;
open
(
my
$fd
,
"<"
,
$file
) or
return
undef
;
my
$res
=
$self
->update_fd(
$fd
,
$start
,
$size
);
close
(
$fd
);
return
$res
;
}
sub
final($)
{
( run in 0.246 second using v1.01-cache-2.11-cpan-e9199f4ba4c )