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 die "cannot read given zipfile";
30 $self->archived_zip($archived_zip);
34 #Assuming that zipfile is a flat list of files.
37 my @file_names = $self->archived_zip()->memberNames();
38 my @file_names_stripped;
40 foreach (@file_names) {
41 my @zip_names_split = split(/\//, $_);
42 if ($zip_names_split[1]) {
43 if ($zip_names_split[1] ne '.DS_Store' && $zip_names_split[1] ne '.fieldbook' && $zip_names_split[1] ne '.thumbnails') {
44 my @zip_names_split_ext = split(/\./, $zip_names_split[1]);
45 push @file_names_stripped, $zip_names_split_ext[0];
46 push @file_names_full, $zip_names_split[1];
51 return (\
@file_names_stripped, \
@file_names_full);
57 my @file_members = $self->archived_zip()->members();
58 #print STDERR Dumper \@file_members;
60 foreach (@file_members) {
61 if (exists($seen_files{$_->{'fileName'}}) || $_->{'compressedSize'} == 0 || index($_->{'fileName'}, '.DS_Store') != -1 || index($_->{'fileName'}, '.fieldbook') != -1 || index($_->{'fileName'}, '.thumbnails') != -1) {
64 $seen_files{$_->{'fileName'}} = 1;
65 push @ret_members, $_;
71 sub extract_files_into_tempdir
{