IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 23, 2008, 1:33:25 PM (18 years ago)
Author:
eugene
Message:

adding outroot_prepare

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/PS-IPP-Config/lib/PS/IPP/Config.pm

    r15852 r16207  
    11# Copyright (c) 2006  Paul Price, Joshua Hoblitt
    22#
    3 # $Id: Config.pm,v 1.72 2007-12-16 22:14:18 eugene Exp $
     3# $Id: Config.pm,v 1.73 2008-01-23 23:33:25 eugene Exp $
    44
    55package PS::IPP::Config;
     
    462462}
    463463
     464# Prepare to receive a new file --- create the directory, if appropriate.  Return the appropriate filename
     465# Does not register anything with Nebulous
     466sub outroot_prepare
     467{
     468    my $self = shift;           # Configuration object
     469    my $outroot = shift;        # Working directory
     470
     471    # outroot is a directory + fragement of a filename
     472
     473    my $scheme = file_scheme($outroot); # The scheme, e.g., file://, path://
     474    return 1 if defined $scheme and lc($scheme) eq 'neb'; # Nothing to be done: Nebulous handles it all
     475
     476    # Might need to create a directory
     477    # not guaranteed to have a scheme (path:// or file://) - might be /PATH/foobar
     478    # a relative path (PATH/foobar) is invalid here
     479    my $resolved = $self->convert_filename_absolute( $outroot );
     480    my ( $vol, $dirs, $file ) = File::Spec->splitpath( $resolved );
     481    unless (-d $dirs) {
     482        system("mkdir -p $dirs") == 0 or (carp "Can't create directory $dirs" and exit($PS_EXIT_DATA_ERROR));
     483    }
     484
     485    return 1;
     486}
    464487
    465488# Convert a relative filename (e.g., "path://PATH/file") to an absolute (e.g., "/path/to/file")
Note: See TracChangeset for help on using the changeset viewer.