IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 29702


Ignore:
Timestamp:
Nov 8, 2010, 2:24:42 PM (16 years ago)
Author:
rhenders
Message:

improvments to temp file handling

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/czartool/CzarDb.pm

    r29686 r29702  
    55use warnings;
    66use strict;
     7
     8use File::Temp;
    79
    810my @stages = ("burntool", "chip", "cam", "fake", "warp", "stack", "diff", "magic", "magicDS", "dist"); # TODO put elsewhere
     
    573575    $query->execute;
    574576
    575     ${$dataFile} = "/tmp/czarplot_gnuplot_".$label."_".$stage."_t.dat";
     577    my $tmpFile = File::Temp->new( TEMPLATE => "czarplot_gnuplot_".$label."_".$stage."_t.XXXXX", DIR => '/tmp', SUFFIX => '.dat');
     578    $tmpFile->unlink_on_destroy( 0 );
     579    ${$dataFile} = $tmpFile->filename;
    576580    open (GNUDAT, ">${$dataFile}") or print "* Problem opening gnuplot data file for plot for '$label' '$stage'\n";
    577581
     
    726730###########################################################################
    727731sub createHostsData {
    728     my ($self, $limit) = @_;
    729 
    730     my $dataFile = "/tmp/czarplot_hosts_space.dat";
    731     open (GNUDAT, ">$dataFile");
     732    my ($self, $limit, $tmpFile) = @_;
     733
     734    open (GNUDAT, ">".$tmpFile->filename);
    732735
    733736    my $query = $self->{_db}->prepare(<<SQL);
     
    775778        print GNUDAT "\n";
    776779    }
     780
    777781    close(GNUDAT);
    778 
    779     return $dataFile;
    780782}
    781783
     
    861863    my $faults;
    862864    my $timestamp;
    863     ${$dataFile} = "/tmp/czarplot_gnuplot_".$label."_".$stage."_r.dat";
     865
     866    my $tmpFile = File::Temp->new( TEMPLATE => "czarplot_gnuplot_".$label."_".$stage."_r.XXXXX", DIR => '/tmp', SUFFIX => 'dat');
     867    $tmpFile->unlink_on_destroy( 0 );
     868    ${$dataFile} = $tmpFile->filename;
     869
    864870    open (GNUDAT, ">${$dataFile}") or print "* Problem opening gnuplot data file for plot for '$label' '$stage'\n";
    865871    my $cleanupCarry = 0;
Note: See TracChangeset for help on using the changeset viewer.