### ### Copyright 2000-2007 University of Illinois Board of Trustees ### All rights reserved. ### ### PSGConf::Action::CreateFile - create file action type for psgconf ### ### Campus Information Technologies and Educational Services ### University of Illinois at Urbana-Champaign ### package PSGConf::Action::CreateFile; use strict; use File::Copy; use PSGConf::Action::File; our @ISA = qw(PSGConf::Action::File); ############################################################################### ### check method ############################################################################### sub check { my ($self, $psgconf) = @_; local *FP; $self->_set_tmpfile($psgconf); if ( ! -e $self->{name} ) { open (FP, ">>" . $self->{tmpfile}) || die "Cannot write " . $self->{tmpfile} . ":$!"; close FP; $self->{changed} = 1; } ### check for permission differences $self->PSGConf::Action::ChMod::check($psgconf); ### check for ownership differences $self->PSGConf::Action::ChOwn::check($psgconf); ### check for group differences $self->PSGConf::Action::ChGrp::check($psgconf); return $self->{changed}; } ############################################################################### ### documentation ############################################################################### 1; __END__ =head1 NAME PSGConf::Action::CreateFile - create file action type for PSGConf =head1 SYNOPSIS use PSGConf::Action::CreateFile; $psgconf->register_actions( PSGConf::Action::CreateFile->new( 'name' => '/path/to/file', ... ), ... ); =head1 DESCRIPTION The B module provides a B action class for creating an empty file if it does not already exist. The B class is derived from the B class, but it defines/overrides the following methods: =over 4 =item check() If the file already exists, returns 0. Otherwise, creates an empty tmpfile and returns 1. =item diff() Displays a message indicating that the file needs to be created. =back =head1 BUGS Used to be named PSGConf::Action::TouchFile, but does not work like the Ctouch(1)E> command, hence the name change. =head1 SEE ALSO L L L =cut