### ### Copyright 2000-2007 University of Illinois Board of Trustees ### All rights reserved. ### ### PSGConf::Action::Remove - remove action type for psgconf ### ### Campus Information Technologies and Educational Services ### University of Illinois at Urbana-Champaign ### package PSGConf::Action::Remove; use strict; use File::Path; use PSGConf::Action; our @ISA = qw(PSGConf::Action); ############################################################################### ### check method ############################################################################### sub check { my ($self) = @_; if (-e $self->{name} || -l $self->{name}) { $self->{changed} = 1; return 1; } return 0; } ############################################################################### ### diff method ############################################################################### sub diff { my ($self) = @_; print "###############################################################################\n"; print "### DIFF FOR $self->{name}\n"; print "###############################################################################\n"; print "- REMOVE: $self->{name}\n\n"; } ############################################################################### ### do() method ############################################################################### sub do { my ($self, $psgconf) = @_; if (!$self->{backup}) { rmtree($self->{name}); } elsif (! $psgconf->save_file($self->{name}, $self->{backup})) { return -1; } return 1; } ############################################################################### ### documentation ############################################################################### 1; __END__ =head1 NAME PSGConf::Action::Remove - file-removal action class for PSGConf =head1 SYNOPSIS use PSGConf::Action::Remove; $psgconf->register_actions( PSGConf::Action::Remove->new( 'name' => '/path/to/file', ... ), ... ); =head1 DESCRIPTION The B module provides a B action class for removing an entry from the filesystem (regular file, directory, symlink, etc). The B class is derived from the B class, but it defines/overrides the following methods: =over 4 =item check() Checks to see if the file currently exists. =item diff() Prints a message indicating that the file needs to be removed. =item do() Removes the file, optionally saving it under a different name. =back In addition to the attributes supported by the B class, the B class supports the following attributes: =over 4 =item I A boolean flag to indicate whether a backup copy of the existing file will be saved. If enabled, existing files will be saved under their original name but with the prefix ".". Default is no backup. =back =head1 SEE ALSO L L L =cut