### ### Copyright 2000-2007 University of Illinois Board of Trustees ### All rights reserved. ### ### PSGConf::Action::CopyFile - canned file action type for psgconf ### ### Campus Information Technologies and Educational Services ### University of Illinois at Urbana-Champaign ### package PSGConf::Action::CopyFile; use strict; use File::Copy; use PSGConf::Action::File; our @ISA = qw(PSGConf::Action::File); ############################################################################### ### check method ############################################################################### sub check { my ($self, $psgconf) = @_; my ($srcfile); $self->_set_tmpfile($psgconf); $srcfile = "$psgconf->{files_dir}/" if (substr($self->{copy_from}, 0, 1) ne '/'); $srcfile .= $self->{copy_from}; if (!copy($srcfile, $self->{tmpfile})) { warn "\n\t!!! can't copy '$srcfile' to tempfile.\n"; return -1; } ### check for changes return $self->_file_changed($psgconf); } ############################################################################### ### documentation ############################################################################### 1; __END__ =head1 NAME PSGConf::Action::CopyFile - file-copy action class for PSGConf =head1 SYNOPSIS use PSGConf::Action::CopyFile; $psgconf->register_actions( PSGConf::Action::CopyFile->new( 'name' => '/path/to/dest', 'copy_from' => '/path/to/src', ... ), ... ); =head1 DESCRIPTION The B module provides a B action class for creating a file as a copy of another file. The B class is derived from the B class, but it defines/overrides the following methods: =over 4 =item check() Generates a tmpfile with the contents of the file to be copied. If the tmpfile differs from the existing file, or if the existing file's permissions or ownership needs to be changed, returns 1. Returns 0 if no changes are needed, or -1 on error. =back In addition to the attributes supported by the B class, the B class supports the following attributes: =over 4 =item I Path to file to be copied. If not an absolute path, it will be searched for in the directory named by the B object's I attribute. =back =head1 SEE ALSO L L L =cut