IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 15085


Ignore:
Timestamp:
Sep 28, 2007, 11:10:58 AM (19 years ago)
Author:
jhoblitt
Message:

create directories as need to the house the files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DataStore/scripts/dsget

    r15082 r15085  
    33# Copyright (C) 2006  Joshua Hoblitt
    44#
    5 # $Id: dsget,v 1.5 2007-09-28 21:05:16 jhoblitt Exp $
     5# $Id: dsget,v 1.6 2007-09-28 21:10:58 jhoblitt Exp $
    66
    77use strict;
     
    4848# can we truely write to filename?
    4949{
    50     # open file for ready/write but not create
     50    # open file for read/write but not create
    5151    my $fh;
    5252    if (open($fh, '+<', $filename)) {
    5353        # do nothing and fall through
    5454    } elsif (open($fh, '>>', $filename)) {
     55        # this is the "stomp on it behavior" this probably shouldn't be the
     56        # default and it may make sense to check the md5sum/bytes count of the
     57        # files that's already in place to see if we really need to re-fetch it
    5558        unlink $filename or die "can't unlink $filename: $!";
    5659    } else {
     
    5962}
    6063
     64my $dirname = dirname($filename);
     65
     66if (!-d $dirname) {
     67    # create path and possibly fix up permissions
     68    mkpath([$dirname], 1, 0775);
     69}
     70
    6171my $tmp = File::Temp->new(
    62     DIR         => dirname($filename),
     72    DIR         => $dirname,
    6373    TEMPLATE    => '.' . basename($filename) . 'XXXX',
    6474    SUFFIX      => '.tmp',
Note: See TracChangeset for help on using the changeset viewer.