5 use Archive
::Zip
qw( :ERROR_CODES :CONSTANTS );
6 use SGN
::Model
::Cvterm
;
9 has
'archived_zipfile_path' => (isa
=> 'Str',
14 has
'extract_directory' => (isa
=> 'Str',
18 has
'archived_zip' => (isa
=> 'Archive::Zip::Archive',
23 my $archived_zip = Archive
::Zip
->new();
27 unless ( $archived_zip->read( $self->archived_zipfile_path() ) == AZ_OK
) {
28 print STDERR
"cannot read given zipfile\n";
31 $self->archived_zip($archived_zip);
35 #Assuming that zipfile is a flat list of files.
38 if (!$self->archived_zip){
41 my @file_names = $self->archived_zip()->memberNames();
42 my @file_names_stripped;
44 foreach (@file_names) {
45 my @zip_names_split = split(/\//, $_);
46 if ($zip_names_split[1]) {
47 if ($zip_names_split[1] ne '.DS_Store' && $zip_names_split[1] ne '.fieldbook' && $zip_names_split[1] ne '.thumbnails') {
48 my @zip_names_split_ext = split(/\./, $zip_names_split[1]);
49 push @file_names_stripped, $zip_names_split_ext[0];
50 push @file_names_full, $zip_names_split[1];
55 return (\
@file_names_stripped, \
@file_names_full);
61 if (!$self->archived_zip){
64 my @file_members = $self->archived_zip()->members();
65 #print STDERR Dumper \@file_members;
67 foreach (@file_members) {
68 if (exists($seen_files{$_->{'fileName'}}) || $_->{'compressedSize'} == 0 || index($_->{'fileName'}, '.DS_Store') != -1 || index($_->{'fileName'}, '.fieldbook') != -1 || index($_->{'fileName'}, '.thumbnails') != -1) {
71 $seen_files{$_->{'fileName'}} = 1;
72 push @ret_members, $_;
78 sub extract_files_into_tempdir
{