aboutsummaryrefslogtreecommitdiffstats
path: root/Perl
diff options
context:
space:
mode:
authorDenis Barbier <barbier>2002-11-17 20:48:05 +0000
committerDenis Barbier <barbier>2002-11-17 20:48:05 +0000
commit6a72d296e668bb9b6abef08ec52ce8888f494a95 (patch)
tree95dc4346511bc68606afb4a892b74091d4500c3b /Perl
parentada80b9f7c333f5c420c02ad8ed6a3df3df395be (diff)
Read and write can now deal with gzipped files
CVS version numbers Perl/Webwml/L10n/Db.pm: 1.12 -> 1.13
Diffstat (limited to 'Perl')
-rw-r--r--Perl/Webwml/L10n/Db.pm17
1 files changed, 13 insertions, 4 deletions
diff --git a/Perl/Webwml/L10n/Db.pm b/Perl/Webwml/L10n/Db.pm
index 6622a82c7c4..8145fb8ee67 100644
--- a/Perl/Webwml/L10n/Db.pm
+++ b/Perl/Webwml/L10n/Db.pm
@@ -149,7 +149,11 @@ sub read {
my $self = shift;
my $file = shift;
- return 0 unless open (DB,"< $file");
+ if ($file =~ m/\.gz$/) {
+ open (DB,"gzip -dc $file |") || return 0;
+ } else {
+ open (DB,"< $file") || return 0;
+ }
$self->{date} = <DB>;
return 0 unless defined($self->{date});
@@ -227,8 +231,13 @@ sub write {
my $file = shift;
my ($text, $line);
- open (DB,"> $file")
- || die "Unable to write to $file\n";
+ if ($file =~ m/\.gz$/) {
+ open (DB,"| gzip -c > $file")
+ || die "Unable to write to $file\n";
+ } else {
+ open (DB,"> $file")
+ || die "Unable to write to $file\n";
+ }
printf DB "%d-%02d-%02d\n\n", Time::localtime::localtime->year() + 1900, Time::localtime::localtime->mon() + 1, Time::localtime::localtime->mday;
foreach my $pkg (sort keys %{$self->{data}}) {
@@ -254,7 +263,7 @@ sub write {
}
print DB "\n";
}
- close DB;
+ close (DB) || die "Unable to close $file\n";
}
=item list_packages

© 2014-2024 Faster IT GmbH | imprint | privacy policy