blib/lib/VCS/LibCVS/Datum/FileMode.pm

filter: Statementstmt 46.6% 14 / 30 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 4 / 8 Podpod 100% 1 / 1 totaltotal 38.7% 19 / 49 CC 6 SCAR 22.6
CC
6
Cov
35%
_n2s_digit
20.0
new
12.0
_data_names
2.0
CRAP 9.5
« blib/lib/VCS/LibCVS/Client/LoggingIOHandle.pm ↑ Summary blib/lib/VCS/LibCVS/FileRevision.pm »
1 #
2 # Copyright (c) 2003,2004,2005 Alexander Taler (dissent@0--0.org)
3 #
4 # All rights reserved. This program is free software; you can redistribute it
5 # and/or modify it under the same terms as Perl itself.
6 #
7  
8 package VCS::LibCVS::Datum::FileMode;
9  
10 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 =head1 NAME
14  
15 VCS::LibCVS::Datum::FileMode - A CVS datum for the mode of a file
16  
17 =head1 SYNOPSIS
18  
19 $string = VCS::LibCVS::Datum::FileMode->new("u=rw,g=rw,o=r");
20  
21 =head1 DESCRIPTION
22  
23 The mode of a file, simple UNIX-style file permissions, like "u=rw,g=rw,o=r".
24  
25 =head1 SUPERCLASS
26  
27 VCS::LibCVS::Datum
28  
29 =cut
30  
31 ###############################################################################
32 # Class constants
33 ###############################################################################
34  
35 1 ▶use constant REVISION => '$Header: /cvsroot/libcvs-perl/libcvs-perl/VCS/LibCVS/Datum/FileMode.pm,v 1.10 2005/10/10 12:52:12 dissent Exp $ ';
Subroutine BEGIN: called CC=1 SCAR=0.0
36  
37 1 ▶use vars ('@ISA');
Subroutine BEGIN: called CC=1 SCAR=0.0
38 1 @ISA = ("VCS::LibCVS::Datum");
39  
40 ###############################################################################
41 # Class variables
42 ###############################################################################
43  
44 ###############################################################################
45 # Private variables
46 ###############################################################################
47  
48 ###############################################################################
49 # Class routines
50 ###############################################################################
51  
52 0 ▶sub new {
Subroutine new: not called CC=3 SCAR=24.8
Pod documented
53 0 my $class = shift;
54 0 my $that = $class->SUPER::new(@_);
55  
56 0 ▶ if ($that->{Mode} !~ /^([ugo]+=[rwx]*)(,[ugo]+=[rwx]*)+$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($that->{"Mode"} =~ /^([ugo]+=[rwx]*)(,[ugo]+=[rwx]*)+$/) 0 0 0
57 0 ▶ if (-e $that->{Mode}) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $that->{'Mode'}) { } 0 0 0
58 0 $that->_from_filename();
59 } else {
60 0 confess "Bad mode: $that->{Mode}"
61 }
62 }
63  
64 0 return $that;
65 }
66  
67 ###############################################################################
68 # Instance routines
69 ###############################################################################
70  
71 ###############################################################################
72 # Private routines
73 ###############################################################################
74  
75 0 ▶sub _data_names { return ("Mode"); }
Subroutine _data_names: not called CC=1 SCAR=6.9
76  
77 # Get the mode of the file from its name
78 0 ▶sub _from_filename {
Subroutine _from_filename: not called CC=1 SCAR=6.9
79 0 my $self = shift;
80 0 my $num = (stat($self->{Mode}))[2] & 0777;
81 0 my $sym = "u=" . _n2s_digit($num >> 6) . ",";
82 0 $sym .= "g=" . _n2s_digit($num >> 3) . ",";
83 0 $sym .= "o=" . _n2s_digit($num);
84 0 $self->{Mode} = $sym;
85 }
86  
87 # Convert a single digit from numerical to symbolic
88 0 ▶sub _n2s_digit {
Subroutine _n2s_digit: not called CC=4 SCAR=30.0
89 0 my $n = shift;
90 0 ▶ return (($n & 04)?"r":"") . (($n & 02)?"w":"") . (($n & 01)?"x":"");
Branch: 3 branches
BranchTrueFalseTotal
$n & 4 ? : 0 0 0
$n & 2 ? : 0 0 0
$n & 1 ? : 0 0 0
91 }
92  
93 =head1 SEE ALSO
94  
95 VCS::LibCVS::Datum
96  
97 =cut
98  
99 1 1;
« blib/lib/VCS/LibCVS/Client/LoggingIOHandle.pm ↑ Summary blib/lib/VCS/LibCVS/FileRevision.pm »