File Coverage

blib/lib/File/lchown.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             # You may distribute under the terms of either the GNU General Public License
2             # or the Artistic License (the same terms as Perl itself)
3             #
4             # (C) Paul Evans, 2010 -- leonerd@leonerd.org.uk
5              
6             package File::lchown;
7              
8 3     3   56180 use strict;
  3         7  
  3         106  
9 3     3   15 use warnings;
  3         5  
  3         134  
10              
11             our $VERSION = '0.02';
12              
13 3     3   22 use Exporter 'import';
  3         5  
  3         243  
14             our @EXPORT_OK = qw(
15             lchown
16             lutimes
17             );
18              
19             require XSLoader;
20             XSLoader::load( __PACKAGE__, $VERSION );
21              
22             =head1 NAME
23              
24             C - modify attributes of symlinks without dereferencing them
25              
26             =head1 SYNOPSIS
27              
28             use File::lchown qw( lchown lutimes );
29              
30             lchown $uid, $gid, $linkpath or die "Cannot lchown() - $!";
31              
32             lutimes $atime, $mtime, $linkpath or die "Cannot lutimes() - $!";
33              
34             =head1 DESCRIPTION
35              
36             The regular C system call will dereference a symlink and apply
37             ownership changes to the file at which it points. Some OSes provide system
38             calls that do not dereference a symlink but instead apply their changes
39             directly to the named path, even if that path is a symlink (in much the same
40             way that C will return attributes of a symlink rather than the file at
41             which it points).
42              
43             =cut
44              
45             =head1 FUNCTIONS
46              
47             =cut
48              
49             =head2 $count = lchown $uid, $gid, @paths
50              
51             Set the new user or group ownership of the specified paths, without
52             dereferencing any symlinks. Passing the value C<-1> as either the C<$uid> or
53             C<$gid> will leave that attribute unchanged. Returns the number of files
54             successfully changed.
55              
56             =cut
57              
58             =head2 $count = lutimes $atime, $mtime, @paths
59              
60             Set the access and modification times on the specified paths, without
61             dereferencing any symlinks. Passing C as both C<$atime> and C<$mtime>
62             will update the times to the current system time.
63              
64             Note that for both C and C, if more than one path is given,
65             if later paths succeed after earlier failures, then the value of C<$!> will
66             not be reliable to indicate the nature of the failure. If you wish to use
67             C<$!> to report on failures, make sure only to pass one path at a time.
68              
69             =cut
70              
71             # Keep perl happy; keep Britain tidy
72             1;
73              
74             __END__