[Lxr-commits] CVS: lxr/lib/LXR/Files Plain.pm,1.16,1.17
Brought to you by:
ajlittoz
|
From: Malcolm B. <mb...@us...> - 2002-02-03 08:12:56
|
Update of /cvsroot/lxr/lxr/lib/LXR/Files
In directory usw-pr-cvs1:/tmp/cvs-serv32307
Modified Files:
Plain.pm
Log Message:
Fix bug in tmp filename generation so that if two tmpfiles are generated in
the same second they don't use the same filename.
Fix from Alexander Schuettelkopf.
Index: Plain.pm
===================================================================
RCS file: /cvsroot/lxr/lxr/lib/LXR/Files/Plain.pm,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- Plain.pm 2001/08/15 15:50:27 1.16
+++ Plain.pm 2002/02/03 08:12:53 1.17
@@ -22,6 +22,7 @@
use strict;
use FileHandle;
+use LXR::Common;
sub new {
my ($self, $rootpath) = @_;
@@ -74,10 +75,15 @@
sub tmpfile {
my ($self, $filename, $release) = @_;
- my ($tmp);
+ my ($tmp, $tries);
local ($/) = undef;
- $tmp = '/tmp/lxrtmp.'.time.'.'.$$;
+ $tmp = $config->tmpdir.'/lxrtmp.'.time.'.'.$$;
+ $tries=0;
+ while ( -e $tmp.$tries) {
+ $tries++;
+ }
+ $tmp.=$tries;
open(TMP, "> $tmp") || return undef;
open(FILE, $self->toreal($filename, $release)) || return undef;
print(TMP <FILE>);
|