### ### Copyright 2000-2007 University of Illinois Board of Trustees ### All rights reserved. ### ### PSGConf::Action::TouchFile - touch file action type for psgconf ### ### Campus Information Technologies and Educational Services ### University of Illinois at Urbana-Champaign ### package PSGConf::Action::TouchFile; use strict; 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}; } ############################################################################### ### diff method ############################################################################### sub diff { my ($self, $psgconf) = @_; print "###############################################################################\n"; print "### DIFF FOR $self->{name}\n"; print "###############################################################################\n"; print "+ touch $self->{name}\n\n"; ### check for permission differences $self->PSGConf::Action::ChMod::diff($psgconf); ### check for ownership differences $self->PSGConf::Action::ChOwn::diff($psgconf); ### check for group differences $self->PSGConf::Action::ChGrp::diff($psgconf); } ############################################################################### ### do method ############################################################################### sub do { my ($self, $psgconf) = @_; my ($t) = time; $self->SUPER::do($psgconf); $t = $self->{timestamp} if ( exists $self->{timestamp} ); if (!utime($t, $t, $self->{name})) { warn "\n\t!!! can't update timestamp (" . $self->{name} . ")\n"; return -1; } return 1; } ############################################################################### ### documentation ############################################################################### 1; __END__ =head1 NAME PSGConf::Action::TouchFile - touch file action type for psgconf =head1 SYNOPSIS use PSGConf::Action::TouchFile; $psgconf->register_actions( PSGConf::Action::TouchFile->new( 'name' => '/path/to/file', ... ), ... ); =head1 DESCRIPTION The B module provides a B action class for updating the timestamp a file. 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 touched. =back =head1 SEE ALSO L Ctouch(1)E> L L L =cut