Update of /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26434/lib/OpenInteract2
Modified Files:
Util.pm
Log Message:
transferring sample files on website upgrades now works as expected -- files with the same content will not be copied; files in the .no_overwrite will not be copied
Index: Util.pm
===================================================================
RCS file: /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Util.pm,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** Util.pm 5 Dec 2004 08:56:49 -0000 1.13
--- Util.pm 5 Dec 2004 20:01:35 -0000 1.14
***************
*** 4,7 ****
--- 4,8 ----
use strict;
+ use Digest::MD5;
use Log::Log4perl qw( get_logger );
use Mail::Sendmail ();
***************
*** 58,66 ****
my ( $class, $filename ) = @_;
unless ( -f $filename ) {
! oi_error "Cannot open [$filename]: file does not exist";
}
eval { open( MOD, '<', $filename ) || die $! };
if ( $@ ) {
! oi_error "Cannot open [$filename]: $@";
}
my @lines = ();
--- 59,67 ----
my ( $class, $filename ) = @_;
unless ( -f $filename ) {
! oi_error "Cannot open '$filename': file does not exist";
}
eval { open( MOD, '<', $filename ) || die $! };
if ( $@ ) {
! oi_error "Cannot read '$filename': $@";
}
my @lines = ();
***************
*** 80,88 ****
my ( $class, $filename ) = @_;
unless ( -f $filename ) {
! oi_error "Cannot open [$filename]: file does not exist";
}
eval { open( PF, '<', $filename ) || die $! };
if ( $@ ) {
! oi_error "Cannot open [$filename]: $@";
}
local $/ = undef;
--- 81,89 ----
my ( $class, $filename ) = @_;
unless ( -f $filename ) {
! oi_error "Cannot open '$filename': file does not exist";
}
eval { open( PF, '<', $filename ) || die $! };
if ( $@ ) {
! oi_error "Cannot read '$filename': $@";
}
local $/ = undef;
***************
*** 99,102 ****
--- 100,112 ----
}
+ sub digest_file {
+ my ( $class, $file ) = @_;
+ my $md5 = Digest::MD5->new();
+ open( IN, '<', $file ) || die "Cannot read '$file' for digest: $!";
+ $md5->addfile( *IN );
+ close( IN );
+ return $md5->hexdigest;
+ }
+
########################################
# EMAIL ROUTINES
***************
*** 294,297 ****
--- 304,323 ----
'2003-04-01' for April 1, 2003.
+ =head1 FILE METHODS
+
+ B<read_file_lines( $filename )>
+
+ Returns content of C<$filename> as an arrayref of lines, with blanks
+ and comments skipped.
+
+ B<read_perl_file( $filename )>
+
+ Returns content of C<$flename> evaluated as a Perl data structure.
+
+ B<digest_file( $filename )>
+
+ Returns the hex MD5 digest of C<$filename> contents. (See
+ L<Digest::MD5> for restrictions, notably regarding unicode.)
+
=head1 MAIL METHODS
|