IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 13574


Ignore:
Timestamp:
May 31, 2007, 12:11:49 PM (19 years ago)
Author:
Paul Price
Message:

Adding function to open file for appending.

File:
1 edited

Legend:

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

    r13502 r13574  
    11# Copyright (c) 2006  Paul Price, Joshua Hoblitt
    22#
    3 # $Id: Config.pm,v 1.49 2007-05-24 20:14:20 price Exp $
     3# $Id: Config.pm,v 1.50 2007-05-31 22:11:49 price Exp $
    44
    55package PS::IPP::Config;
     
    296296    my $fh;
    297297    unless (open $fh, '>', $name) {
     298        carp "Unable to create file $name --- $!";
     299        exit($PS_EXIT_SYS_ERROR);
     300    }
     301    return $fh;
     302}
     303
     304# Create and open file for appending
     305sub file_create_append
     306{
     307    my $self = shift;           # Configuration object
     308    my $name = shift;           # File name to check
     309
     310    $self->file_prepare( $name );
     311
     312    my ($scheme) = $name =~ m|^(\S+):|; # The scheme, e.g., file://, path://
     313    if (defined $scheme) {
     314        if ($scheme eq 'neb') {
     315            $name =~ s|^(\S+):/*||;
     316            $self->_neb_start();
     317            return $self->{nebulous}->open_create( $name );
     318        }
     319        if ($scheme eq 'path' or $scheme eq 'file') {
     320            $name = $self->convert_filename_absolute( $name );
     321        }
     322    }
     323
     324    my $fh;
     325    unless (open $fh, '>>', $name) {
    298326        carp "Unable to create file $name --- $!";
    299327        exit($PS_EXIT_SYS_ERROR);
Note: See TracChangeset for help on using the changeset viewer.