Slurp/WithinPolicy.pm

filter: Statementstmt 100% 36 / 36 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 12 / 12 Podpod 100% 5 / 5 totaltotal 100% 53 / 53 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Policy/Default.pm ↑ Summary
1 ###############################################################################
2 # Purpose : Hide site-dependent FS policies beneath a well-known interface
3 # Author : John Alden
4 # Created : March 2005
5 # CVS : $Id: WithinPolicy.pm,v 1.4 2005/06/15 10:40:21 simonf Exp $
6 ###############################################################################
7  
8 package File::Slurp::WithinPolicy;
9  
10 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use Fcntl ':flock';
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 ▶use File::Slurp();
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 ▶use File::Policy;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 2 ▶use vars qw($VERSION @EXPORT_OK %EXPORT_TAGS @ISA);
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 2 @ISA = qw(Exporter);
19 2 @EXPORT_OK = qw(read_file write_file append_file overwrite_file read_dir);
20 2 %EXPORT_TAGS = ('all' => \@EXPORT_OK);
21 2 $VERSION = sprintf"%d.%03d", q$Revision: 1.4 $ =~ /: (\d+)\.(\d+)/;
22  
23 8 ▶sub read_file {
Subroutine read_file: called CC=1 SCAR=0.0
Pod documented
24 8 File::Policy::check_safe( $_[0], 'r' );
25 8 goto &File::Slurp::read_file;
26 }
27  
28 4 ▶sub write_file {
Subroutine write_file: called CC=1 SCAR=0.0
Pod documented
29 4 File::Policy::check_safe( $_[0], 'w' );
30 4 goto &File::Slurp::write_file;
31 }
32  
33 20 ▶sub append_file {
Subroutine append_file: called CC=1 SCAR=0.0
Pod documented
34 20 File::Policy::check_safe( $_[0], 'w' );
35 20 goto &File::Slurp::append_file;
36 }
37  
38 1 ▶sub overwrite_file {
Subroutine overwrite_file: called CC=1 SCAR=0.0
Pod documented
39 1 File::Policy::check_safe( $_[0], 'w' );
40 1 goto &File::Slurp::overwrite_file;
41 }
42  
43 1 ▶sub read_dir {
Subroutine read_dir: called CC=1 SCAR=0.0
Pod documented
44 1 File::Policy::check_safe( $_[0], 'r' );
45 1 goto &File::Slurp::read_dir;
46 }
47  
48 2 1;
49  
50 =head1 NAME
51  
52 File::Slurp::WithinPolicy - Applies filesystem policies to File::Slurp
53  
54 =head1 SYNOPSIS
55  
56 use File::Slurp::WithinPolicy qw(:all);
57  
58 my $text = read_file( 'filename' );
59 my @lines = read_file( 'filename' );
60 write_file( 'filename', $text );
61 append_file( 'filename', $more_text );
62 overwrite_file( 'filename', $text );
63 my @files = read_dir( '/path/to/dir' );
64  
65 =head1 DESCRIPTION
66  
67 This provides the File::Slurp interface within a policy defined by File::Policy.
68 By default, File::Policy is a no-op and this behaves identically to File::Slurp.
69 System administrators may want to override the default File::Policy implementation to enforce a local filesystem policy
70 (see L<File::Policy>).
71  
72 =head1 FUNCTIONS
73  
74 =head2 read_dir
75  
76 See L<File::Slurp/read_dir>
77  
78 =head2 read_file
79  
80 See L<File::Slurp/read_file>
81  
82 =head2 write_file
83  
84 See L<File::Slurp/write_file>
85  
86 =head2 append_file
87  
88 See L<File::Slurp/append_file>
89  
90 =head2 overwrite_file
91  
92 See L<File::Slurp/overwrite_file>
93  
94 =head1 EXPORTS
95  
96 By default, nothing is exported.
97 The C<:all> tag can be used to export everything.
98 Individual methods can also be exported.
99  
100 =head1 SEE ALSO
101  
102 L<File::Slurp>, L<File::Policy>
103  
104 =head1 VERSION
105  
106 $Revision: 1.4 $ on $Date: 2005/06/15 10:40:21 $ by $Author: simonf $
107  
108 =head1 AUTHOR
109  
110 John Alden <cpan _at_ bbc _dot_ co _dot_ uk>
111  
112 =head1 COPYRIGHT
113  
114 (c) BBC 2005. This program is free software; you can redistribute it and/or modify it under the GNU GPL.
115  
116 See the file COPYING in this distribution, or http://www.gnu.org/licenses/gpl.txt
117  
118 =cut
« Policy/Default.pm ↑ Summary