forked from 0ad/0ad
Updated archive builder, to avoid compressing things which probably don't benefit from it
This was SVN commit r2001.
This commit is contained in:
parent
ae172a9a01
commit
1e52b32f6b
@ -356,10 +356,23 @@ sub create_archive {
|
|||||||
my $zip = new Archive::Zip;
|
my $zip = new Archive::Zip;
|
||||||
|
|
||||||
for my $file (@$files) {
|
for my $file (@$files) {
|
||||||
|
|
||||||
if ($file->[1]->archive) {
|
if ($file->[1]->archive) {
|
||||||
|
|
||||||
$zip->addMember($file->[1]->location) or die "Error adding zipped file $file->[0] to zip";
|
$zip->addMember($file->[1]->location) or die "Error adding zipped file $file->[0] to zip";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$zip->addFile($file->[1]->location, $file->[0]) or die "Error adding file $file->[0] to zip";
|
|
||||||
|
my $member = Archive::Zip::Member->newFromFile($file->[1]->location) or die "Error adding file $file->[0] to zip";
|
||||||
|
$member->fileName($file->[0]);
|
||||||
|
|
||||||
|
if (should_compress($file->[1]->location)) {
|
||||||
|
$member->desiredCompressionMethod(Archive::Zip::COMPRESSION_DEFLATED);
|
||||||
|
} else {
|
||||||
|
$member->desiredCompressionMethod(Archive::Zip::COMPRESSION_STORED);
|
||||||
|
}
|
||||||
|
|
||||||
|
$zip->addMember($member);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -379,4 +392,11 @@ sub get_opt {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $default;
|
return $default;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub should_compress {
|
||||||
|
my ($filename) = @_;
|
||||||
|
return 0 if $filename =~ /\.(ogg|png)$/i; # don't compress things that are already compressed
|
||||||
|
return 0 if (stat $filename)[7] < 8192; # don't compress small files
|
||||||
|
return 1;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user