QuoteIO error: reading data :
at C:/strawberry/perl/site/lib/Archive/Zip/NewFileMember.pm line 60.
Archive::Zip::NewFileMember::_readRawChunk(Archive::Zip::NewFileMember=HASH(0x481e198), SCALAR(0x37cb668), 60) called at C:/strawberry/perl/site/lib/Archive/Zip/Member.pm line 832
Archive::Zip::Member::readChunk(Archive::Zip::NewFileMember=HASH(0x481e198), 32768) called at C:/strawberry/perl/site/lib/Archive/Zip/Member.pm line 1093
Archive::Zip::Member::_writeData(Archive::Zip::NewFileMember=HASH(0x481e198), IO::File=GLOB(0x152fa8e0)) called at C:/strawberry/perl/site/lib/Archive/Zip/Member.pm line 1062
Archive::Zip::Member::_writeToFileHandle(Archive::Zip::NewFileMember=HASH(0x481e198), IO::File=GLOB(0x152fa8e0), 1, 244149035) called at C:/strawberry/perl/site/lib/Archive/Zip/Archive.pm line 420
Archive::Zip::Archive::writeToFileHandle(Archive::Zip::Archive=HASH(0x41baee0), IO::File=GLOB(0x152fa8e0), 1) called at C:/strawberry/perl/site/lib/Archive/Zip/Archive.pm line 389
Archive::Zip::Archive::writeToFileNamed(Archive::Zip::Archive=HASH(0x41baee0), "meinzipfile.zip") called at meinscript.pl line 7267
main::meinesub2(HASH(0x39f1678), HASH(0x39f1828), HASH(0x39f17c8)) called at meinscript.pl line 886
main::meinesub(HASH(0x23f16b8)) called at meinscript.pl line 155
or return (0, _ioError("reading data"));
or return (0, _ioError("reading data: " . $self->{'fileName'}));
2016-01-29T12:01:36 GwenDragonEigentlich kannst du mit Archive::Zip::setErrorHandler() deine eigene Routine zur Fehlerausgabe nehmen.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
#!/usr/bin/perl use strict; use warnings; use 5.010; use Archive::Zip qw(:ERROR_CODES :CONSTANTS); if ($^O =~ /mswin/i) { $Archive::Zip::UNICODE = 1; } # Zufallsdateien erzeugen say '-' x 80; my $nr = 1; $nr ++ while -e "test$nr"; mkdir("test$nr"); for (my $fnr = 1; $fnr < 11; $fnr ++) { open(my $fh,'>',"test$nr/testdatei$fnr.txt"); my $count = int(rand((9000)+1))+100; for (my $x = 0; $x < $count; $x ++) { print $fh chr(int(rand((25)+1))+65); } close($fh); } # ZIPpen my $zip = Archive::Zip->new(); my $error = ''; Archive::Zip::setErrorHandler( # auskommentieren um das ursprüngliche sub{ # und jetzt gelöste Problem zu sehen chomp($_[0]); $error = "FEHLER '$_[0]'"; } ); mkdir('archive_zip_temp') if !-e 'archive_zip_temp'; Archive::Zip::tempFile('archive_zip_temp'); my @pfade = ("test$nr"); my $flag = 0; # 0=wilde Fehlermeldungen erzeugen / sonst 1 while (scalar @pfade) { my $pfad = shift @pfade; if (opendir(my $fh,$pfad)) { foreach my $file (sort {$a cmp $b} readdir $fh) { next if $file eq '.' || $file eq '..'; if (-d "$pfad/$file") { push @pfade,"$pfad/$file"; } else { if (open(my $t,'<',"$pfad/$file")) { close($t); my $file_member = $zip->addFile({ filename => "$pfad/$file", compressionLevel => 7, }); if (!$flag) { unlink("$pfad/$file"); # mitten im Vorgang Dateien entziehen... $flag = 1; } say "add '$pfad/$file'"; } else { say "$pfad/$file nicht lesbar" } } } } else { say "$pfad -> $! in ".__LINE__.' -> wird ignoriert, darum geht es im Moment nicht'; } } say '-' x 80; say "Endergebnis: ".$zip->writeToFileNamed('test.zip'); say '-' x 80; if ($error ne '') { say $error; } else { say 'OK'; }