From e13a7b1806e5b9f04def1f67f897bd8695b2e91a Mon Sep 17 00:00:00 2001 From: Olivier Thauvin Date: Sun, 5 Dec 2004 07:13:01 +0000 Subject: - fix data length to write - test: use strict ;) then fix it !! --- packdrakeng.pm | 4 ++-- t/01packdrakeng.t | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packdrakeng.pm b/packdrakeng.pm index 3db9a9f..1ccb7e6 100644 --- a/packdrakeng.pm +++ b/packdrakeng.pm @@ -464,7 +464,7 @@ sub gzip_uncompress { $read += $l; if ($read <= $fileinfo->{off}) { next } - my $bw = $byteswritten + $l > $fileinfo->{size} ? $fileinfo->{size} - $byteswritten : $l; + my $bw = $byteswritten + length($out) > $fileinfo->{size} ? $fileinfo->{size} - $byteswritten : length($out); syswrite($destfh, $out, $bw) == $bw or do { warn "Can't write data into dest"; return -1; @@ -476,7 +476,7 @@ sub gzip_uncompress { } ################### -# Dubug functions # +# Debug functions # ################### # This function extract in $dest the whole bloc containing $file, can be usefull for debugging diff --git a/t/01packdrakeng.t b/t/01packdrakeng.t index 27f0527..0273604 100755 --- a/t/01packdrakeng.t +++ b/t/01packdrakeng.t @@ -2,6 +2,7 @@ # $Id$ +use strict; use Test::More tests => 16; use Digest::MD5; @@ -16,7 +17,7 @@ sub clean_test_files { sub create_test_files { my ($number) = @_; my %created; - -d test or mkdir test; + -d "test" or mkdir "test"; foreach my $n (1 .. $number||10) { my $size = int(rand(1024)); # push(@created, "test/$size"); @@ -29,7 +30,8 @@ sub create_test_files { } sub create_know_file { - foreach my $letter (a..z) { + my %created; + foreach my $letter ('a' .. 'z') { open(my $h, "> test/$letter"); foreach (1 .. 3456) { printf $h "%s\n", $letter x 33; @@ -72,8 +74,8 @@ sub test_packing { clean_test_files(); ok($pack = packdrakeng->open(%$pack_param), "Re-opening the archive"); - ok($pack->extract(undef, keys(%createdfiles)), "extracting files"); - ok(check_files(%createdfiles), "Checking md5sum for extracted files"); + ok($pack->extract(undef, keys(%$listfiles)), "extracting files"); + ok(check_files(%$listfiles), "Checking md5sum for extracted files"); $pack = undef; } -- cgit v1.2.1