aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2005-06-16 01:01:38 +0000
committerRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2005-06-16 01:01:38 +0000
commit3e3d964b8581ee68c2efcd7c46d78c693dcb7b79 (patch)
tree0c8cced6ced1642067415824ad82dd4cb62d462c
parentdbcb8beea9a2ee863ec7b043724f3a80607c5f50 (diff)
downloadrpmtools-3e3d964b8581ee68c2efcd7c46d78c693dcb7b79.tar
rpmtools-3e3d964b8581ee68c2efcd7c46d78c693dcb7b79.tar.gz
rpmtools-3e3d964b8581ee68c2efcd7c46d78c693dcb7b79.tar.bz2
rpmtools-3e3d964b8581ee68c2efcd7c46d78c693dcb7b79.tar.xz
rpmtools-3e3d964b8581ee68c2efcd7c46d78c693dcb7b79.zip
Create temp file in $TMPDIR instead of $TMP, and warn when creation failed
-rw-r--r--Packdrakeng.pm11
1 files changed, 7 insertions, 4 deletions
diff --git a/Packdrakeng.pm b/Packdrakeng.pm
index f46c2b6..ecffd8e 100644
--- a/Packdrakeng.pm
+++ b/Packdrakeng.pm
@@ -29,14 +29,17 @@ my ($toc_header, $toc_footer) =
sub tempfile {
my ($count, $fname, $handle) = (0, undef, undef);
do {
- ++$count > 10 and return (undef, undef);
+ ++$count > 10 and do {
+ warn "Can't create temporary file";
+ return (undef, undef);
+ };
$fname = sprintf("%s/packdrakeng.%s.%s",
- $ENV{TMP} || '/tmp',
+ $ENV{TMPDIR} || '/tmp',
$$,
# Generating an random name
join("", map { $_=rand(51); $_ += $_ > 25 && $_ < 32 ? 91 : 65 ; chr($_) } (0 .. 4)));
- } while ( ! sysopen($handle, $fname, O_WRONLY | O_APPEND | O_CREAT));
- ($handle, $fname)
+ } while !sysopen($handle, $fname, O_WRONLY | O_APPEND | O_CREAT);
+ return ($handle, $fname);
}
# File::Path hack to not require it