| 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 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 3 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | |||
| 11 | 3 | our $VERSION = '0.02'; | |
| 12 | |||
| 13 | 3 | ▶ | use Exporter 'import'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 14 | 3 | our @EXPORT_OK = qw( | |
| 15 | lchown | ||
| 16 | lutimes | ||
| 17 | ); | ||
| 18 | |||
| 19 | 3 | require XSLoader; | |
| 20 | 3 | XSLoader::load( __PACKAGE__, $VERSION ); | |
| 21 | |||
| 22 | =head1 NAME | ||
| 23 | |||
| 24 | C<File::lchown> - 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<chown> 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<lstat> 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<undef> as both C<$atime> and C<$mtime> | ||
| 62 | will update the times to the current system time. | ||
| 63 | |||
| 64 | Note that for both C<lchown> and C<lutimes>, 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 | 3 | 1; | |
| 73 | |||
| 74 | __END__ | ||