File::Slurp::WithinPolicy - Applies filesystem policies to File::Slurp


File-Policy documentation Contained in the File-Policy distribution.

Index


Code Index:

NAME

Top

File::Slurp::WithinPolicy - Applies filesystem policies to File::Slurp

SYNOPSIS

Top

  use File::Slurp::WithinPolicy qw(:all);

  my $text = read_file( 'filename' );
  my @lines = read_file( 'filename' );
  write_file( 'filename', $text );
  append_file( 'filename', $more_text );
  overwrite_file( 'filename', $text );
  my @files = read_dir( '/path/to/dir' );

DESCRIPTION

Top

This provides the File::Slurp interface within a policy defined by File::Policy. By default, File::Policy is a no-op and this behaves identically to File::Slurp. System administrators may want to override the default File::Policy implementation to enforce a local filesystem policy (see File::Policy).

FUNCTIONS

Top

read_dir

See read_dir in File::Slurp

read_file

See read_file in File::Slurp

write_file

See write_file in File::Slurp

append_file

See append_file in File::Slurp

overwrite_file

See overwrite_file in File::Slurp

EXPORTS

Top

By default, nothing is exported. The :all tag can be used to export everything. Individual methods can also be exported.

SEE ALSO

Top

File::Slurp, File::Policy

VERSION

Top

$Revision: 1.4 $ on $Date: 2005/06/15 10:40:21 $ by $Author: simonf $

AUTHOR

Top

John Alden <cpan _at_ bbc _dot_ co _dot_ uk>

COPYRIGHT

Top


File-Policy documentation Contained in the File-Policy distribution.

###############################################################################
# Purpose : Hide site-dependent FS policies beneath a well-known interface
# Author  : John Alden
# Created : March 2005
# CVS     : $Id: WithinPolicy.pm,v 1.4 2005/06/15 10:40:21 simonf Exp $
###############################################################################

package File::Slurp::WithinPolicy;

use strict;
use Carp;
use Exporter;
use Fcntl ':flock';
use File::Slurp();
use File::Policy;
use vars qw($VERSION @EXPORT_OK %EXPORT_TAGS @ISA);

@ISA = qw(Exporter);
@EXPORT_OK = qw(read_file write_file append_file overwrite_file read_dir);
%EXPORT_TAGS = ('all' => \@EXPORT_OK);
$VERSION = sprintf"%d.%03d", q$Revision: 1.4 $ =~ /: (\d+)\.(\d+)/;

sub read_file {	
	File::Policy::check_safe( $_[0], 'r' );
	goto &File::Slurp::read_file;
}

sub write_file {	
	File::Policy::check_safe( $_[0], 'w' );
	goto &File::Slurp::write_file;
}

sub append_file {	
	File::Policy::check_safe( $_[0], 'w' );
	goto &File::Slurp::append_file;
}

sub overwrite_file {	
	File::Policy::check_safe( $_[0], 'w' );
	goto &File::Slurp::overwrite_file;
}

sub read_dir {	
	File::Policy::check_safe( $_[0], 'r' );
	goto &File::Slurp::read_dir;
}

1;