[Po4a-devel][CVS] po4a/lib/Locale/Po4a TransTractor.pm,1.28,1.29 Po.pm,1.17,1.18
Martin Quinson
po4a-devel@lists.alioth.debian.org
Sat, 07 Aug 2004 02:15:10 +0000
Update of /cvsroot/po4a/po4a/lib/Locale/Po4a
In directory haydn:/tmp/cvs-serv22132/lib/Locale/Po4a
Modified Files:
TransTractor.pm Po.pm
Log Message:
TransTractor and Po mkdir the path to where they are asked to write something if it does not exist. Clauses #263297 (in Debian)
Index: Po.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/Po.pm,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- Po.pm 6 Aug 2004 22:48:51 -0000 1.17
+++ Po.pm 7 Aug 2004 02:15:07 -0000 1.18
@@ -72,6 +72,7 @@
use Carp qw(croak);
use Locale::gettext qw(dgettext);
+use File::Path; # mkdir before write
my @known_flags=qw(wrap no-wrap c-format fuzzy);
@@ -218,6 +219,13 @@
if ($filename eq '-') {
$fh=\*STDOUT;
} else {
+ # make sure the directory in which we should write the localized file exists
+ my $dir = $filename;
+ $dir =~ s|/[^/]*$||;
+
+ File::Path::mkpath($dir, 0, 0755) # Croaks on error
+ if (length ($dir) && ! -e $dir);
+
open $fh,">$filename"
|| croak (sprintf((dgettext("po4a","Can't write to %s: %s"),$filename,$!))."\n");
}
Index: TransTractor.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/TransTractor.pm,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- TransTractor.pm 5 Aug 2004 12:19:59 -0000 1.28
+++ TransTractor.pm 7 Aug 2004 02:15:07 -0000 1.29
@@ -20,6 +20,7 @@
use Locale::Po4a::Po;
use Locale::gettext qw(dgettext);
+use File::Path; # mkdir before write
use Encode::Guess;
@@ -378,7 +379,14 @@
if ($filename eq '-') {
$fh=\*STDOUT;
} else {
- open $fh,">$filename"
+ # make sure the directory in which we should write the localized file exists
+ my $dir = $filename;
+ $dir =~ s|/[^/]*$||;
+
+ File::Path::mkpath($dir, 0, 0755) # Croaks on error
+ if (length ($dir) && ! -e $dir);
+
+ open $fh,">$filename"
|| croak (sprintf((dgettext("po4a","can't write to %s: %s"),$filename,$!))."\n");
}