Revision 91751883
Von Jan Büren vor fast 5 Jahren hinzugefügt
SL/GoBD.pm | ||
---|---|---|
10 | 10 |
|
11 | 11 |
use Text::CSV_XS; |
12 | 12 |
use XML::Writer; |
13 |
use Archive::Zip; |
|
14 | 13 |
use File::Temp (); |
15 | 14 |
use File::Spec (); |
15 |
use IO::Compress::Zip qw(zip $ZipError); |
|
16 | 16 |
use List::MoreUtils qw(any); |
17 | 17 |
use List::UtilsBy qw(partition_by sort_by); |
18 | 18 |
|
... | ... | |
180 | 180 |
|
181 | 181 |
# make zip |
182 | 182 |
my ($fh, $zipfile) = File::Temp::tempfile(); |
183 |
my $zip = Archive::Zip->new; |
|
184 |
|
|
183 |
my (@files, %name_subs); |
|
185 | 184 |
while (my ($name, $file) = each %{ $self->files }) { |
186 |
$zip->addFile($file, $name); |
|
185 |
push @files, $file; |
|
186 |
$name_subs{$file} = $name; |
|
187 | 187 |
} |
188 | 188 |
|
189 |
$zip->writeToFileHandle($fh) == Archive::Zip::AZ_OK() or die 'error writing zip file';
|
|
190 |
close($fh);
|
|
189 |
zip \@files => $zipfile, FilterName => sub { s/.*/$name_subs{$_}/; }
|
|
190 |
or die "zip failed: $ZipError\n";
|
|
191 | 191 |
|
192 | 192 |
return $zipfile; |
193 | 193 |
} |
bin/mozilla/datev.pl | ||
---|---|---|
27 | 27 |
#====================================================================== |
28 | 28 |
|
29 | 29 |
use POSIX qw(strftime getcwd); |
30 |
use Archive::Zip qw(:ERROR_CODES :CONSTANTS);
|
|
30 |
use IO::Compress::Zip qw(zip $ZipError);
|
|
31 | 31 |
|
32 | 32 |
use SL::Common; |
33 | 33 |
use SL::DATEV qw(:CONSTANTS); |
... | ... | |
150 | 150 |
|
151 | 151 |
$::auth->assert('datev_export'); |
152 | 152 |
|
153 |
my $tmp_name = Common->tmpname(); |
|
154 | 153 |
my $zip_name = strftime("kivitendo-datev-export-%Y%m%d.zip", localtime(time())); |
155 | 154 |
|
156 | 155 |
my $cwd = getcwd(); |
... | ... | |
171 | 170 |
$form->error($locale->text("Your download does not exist anymore. Please re-run the DATEV export assistant.")); |
172 | 171 |
} |
173 | 172 |
|
174 |
my $zip = Archive::Zip->new(); |
|
175 |
map { $zip->addFile($_); } @filenames; |
|
176 |
$zip->writeToFileNamed($tmp_name); |
|
173 |
zip \@filenames => $zip_name or die "zip failed: $ZipError\n"; |
|
177 | 174 |
|
178 | 175 |
chdir($cwd); |
179 | 176 |
|
180 |
open(IN, $tmp_name) || die("open $tmp_name");
|
|
177 |
open(IN, $path . $zip_name) || die("open $path");
|
|
181 | 178 |
$::locale->with_raw_io(\*STDOUT, sub { |
182 | 179 |
print("Content-Type: application/zip\n"); |
183 | 180 |
print("Content-Disposition: attachment; filename=\"${zip_name}\"\n\n"); |
... | ... | |
187 | 184 |
}); |
188 | 185 |
close(IN); |
189 | 186 |
|
190 |
unlink($tmp_name); |
|
191 |
|
|
192 | 187 |
$main::lxdebug->leave_sub(); |
193 | 188 |
} |
194 | 189 |
|
Auch abrufbar als: Unified diff
DATEV- und GoBD-Export auf Compress::IO umgestellt