###
###  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<PSGConf::Action::CreateFile> module provides a B<PSGConf> action
class for creating an empty file if it does not already exist.

The B<PSGConf::Action::CreateFile> class is derived from the
B<PSGConf::Action::File> 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 C<CE<lt>touch(1)E<gt>> command, hence the name change.

=head1 SEE ALSO

L<perl>

L<PSGConf>

L<PSGConf::Action::File>

=cut



syntax highlighted by Code2HTML, v. 0.9.1