POSIX/Directory.pm

filter: Statementstmt 100% 26 / 26 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 16 / 16 Podpod 100% 13 / 13 totaltotal 100% 55 / 55 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« POSIX/Bits.pm ↑ Summary
1 # Copyright (c) 2014, cPanel, Inc.
2 # All rights reserved.
3 # http://cpanel.net/
4 #
5 # This is free software; you can redistribute it and/or modify it under the same
6 # terms as Perl itself. See the LICENSE file for further details.
7  
8 package Filesys::POSIX::Directory;
9  
10 27 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 27 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 27 ▶use Carp qw(confess);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 =head1 NAME
16  
17 Filesys::POSIX::Directory - Base class for implementing directory structures
18  
19 =head1 DESCRIPTION
20  
21 Filesys::POSIX::Directory is a common interface used to implement classes that
22 act like directories, and should be able to be accessed randomly or in an
23 iterative fashion.
24  
25 Classes which wish to implement the interface documented herein should provide
26 implementations for ALL methods listed in this document, in the manner in which
27 they are described within this document.
28  
29 =head1 RANDOM ACCESS
30  
31 =over
32  
33 =item C<$directory-E<gt>get($name)>
34  
35 If the current directory contains an item named for C<$name>, return the
36 corresponding inode. Otherwise, an C<undef> is returned.
37  
38 =cut
39  
40 1 ▶sub get {
Subroutine get: called CC=1 SCAR=0.0
Pod documented
41 1 confess('Not implemented');
42 }
43  
44 =item C<$directory-E<gt>set($name, $inode)>
45  
46 Store a reference to C<$inode> in the current directory, named after the member
47 label C<$name>. If an item already exists for C<$name>, then it will be
48 replaced by C<$inode>.
49  
50 =cut
51  
52 1 ▶sub set {
Subroutine set: called CC=1 SCAR=0.0
Pod documented
53 1 confess('Not implemented');
54 }
55  
56 =item C<$directory-E<gt>exists($name)>
57  
58 Returns true if a member called C<$name> exists in the current directory.
59 Returns false if no such member inode is listed.
60  
61 =cut
62  
63 1 ▶sub exists {
Subroutine exists: called CC=1 SCAR=0.0
Pod documented
64 1 confess('Not implemented');
65 }
66  
67 =item C<$directory-E<gt>detach($name)>
68  
69 Drop any references to a member called C<$name> in the current directory. No
70 side effects outside of the directory object instance shall occur.
71  
72 =cut
73  
74 1 ▶sub detach {
Subroutine detach: called CC=1 SCAR=0.0
Pod documented
75 1 confess('Not implemented');
76 }
77  
78 =item C<$directory-E<gt>delete($name)>
79  
80 Drop any references to a member called C<$name> in the current directory. Side
81 effects to other system resources referenced by this directory member may
82 potentially occur, depending on the specific directory implementation.
83  
84 =cut
85  
86 1 ▶sub delete {
Subroutine delete: called CC=1 SCAR=0.0
Pod documented
87 1 confess('Not implemented');
88 }
89  
90 =back
91  
92 =head1 LIST ACCESS
93  
94 =over
95  
96 =item C<$directory-E<gt>list()>
97  
98 Return a list of all items in the current directory, including C<.> and C<..>.
99  
100 =cut
101  
102 1 ▶sub list {
Subroutine list: called CC=1 SCAR=0.0
Pod documented
103 1 confess('Not implemented');
104 }
105  
106 =item C<$directory-E<gt>count()>
107  
108 Return the number of all items in the current directory, including C<.> and
109 C<..>.
110  
111 =cut
112  
113 1 ▶sub count {
Subroutine count: called CC=1 SCAR=0.0
Pod documented
114 1 confess('Not implemented');
115 }
116  
117 =item C<$directory-E<gt>empty()>
118  
119 Returns true if the directory only contains the C<.> and C<..> entries.
120  
121 =cut
122  
123 4 ▶sub empty {
Subroutine empty: called CC=1 SCAR=0.0
Pod documented
124 4 my ($self) = @_;
125  
126 4 return $self->count == 2;
127 }
128  
129 =back
130  
131 =head1 ITERATIVE ACCESS
132  
133 =over
134  
135 =item C<$directory-E<gt>open()>
136  
137 Prepare the current directory object for iterative reading access.
138  
139 =cut
140  
141 1 ▶sub open {
Subroutine open: called CC=1 SCAR=0.0
Pod documented
142 1 confess('Not implemented');
143 }
144  
145 =item C<$directory-E<gt>rewind()>
146  
147 Rewind the current directory object to the beginning of the directory list when
148 being accessed iteratively.
149  
150 =cut
151  
152 1 ▶sub rewind {
Subroutine rewind: called CC=1 SCAR=0.0
Pod documented
153 1 confess('Not implemented');
154 }
155  
156 =item C<$directory-E<gt>read()>
157  
158 Read and return a single item from the directory, advancing the pointer to the
159 next item to be read, if any. A list containing both the name of the object,
160 and the inode it references, are returned.
161  
162 =cut
163  
164 1 ▶sub read {
Subroutine read: called CC=1 SCAR=0.0
Pod documented
165 1 confess('Not implemented');
166 }
167  
168 =item C<$directory-E<gt>close()>
169  
170 Close the current directory for iterative access.
171  
172 =cut
173  
174 1 ▶sub close {
Subroutine close: called CC=1 SCAR=0.0
Pod documented
175 1 confess('Not implemented');
176 }
177  
178 =item C<$directory-E<gt>rename_member()>
179  
180 Rename an item from one Filesys::POSIX::Directory so that it becomes
181 a member of another Filesys::POSIX::Directory and/or changes name.
182  
183 =cut
184  
185 4 ▶sub rename_member {
Subroutine rename_member: called CC=1 SCAR=0.0
Pod documented
186 4 my ( $self, $inode, $old_dir, $old_name, $new_name ) = @_;
187 4 $old_dir->detach($old_name);
188 4 $self->set( $new_name, $inode );
189 }
190  
191 =back
192  
193 =cut
194  
195 27 1;
196  
197 __END__
« POSIX/Bits.pm ↑ Summary