File Coverage

blib/lib/Cantella/Store/UUID/Util.pm
Criterion Covered Total %
statement 17 19 89.4
branch 4 6 66.6
condition n/a
subroutine 4 4 100.0
pod n/a
total 25 29 86.2


line stmt bran cond sub pod time code
1             package Cantella::Store::UUID::Util;
2              
3 2     2   160728 use strict;
  2         5  
  2         78  
4 2     2   14 use warnings;
  2         3  
  2         79  
5              
6 2     2   3700 use Sub::Exporter -setup => { exports => [ '_mkdirs' ] };
  2         24165  
  2         20  
7              
8             our $VERSION = '0.003003';
9              
10             sub _mkdirs {
11 17     17   1046 my $dir = shift;
12 17         24 my $levels = shift;
13              
14 17         36 --$levels;
15 17         47 for my $node ( (0..9), qw(A B C D E F) ){
16 272         7549 my $subdir = $dir->subdir($node);
17 272 50       24808 if( -f $subdir ){
18 0         0 die("Can't create dir '${subdir}': a file with a conflicting name exists");
19             }
20 272 50       17104 if( ! $subdir->mkpath ){
21 0         0 die("Can't create dir '${subdir}': $!");
22             }
23              
24 272 100       90411 _mkdirs($subdir, $levels) if $levels > 0;
25             }
26             }
27              
28             1;
29              
30             __END__;
31              
32             =head1 NAME
33              
34             Cantella::Store::UUID::Util - Useful things that didn't belong in the objects
35              
36             =head1 SUBROUTINES
37              
38             =head2 _mkdirs $dir, $levels
39              
40             Will recursively make a directory hioerarchy C<$levels> deep using
41             C<$dir> as the root. C<$dir> will not be created.
42              
43             =head1 SEE ALSO
44              
45             L<Cantella::Store::UUID>, L<Cantella::Store::UUID::File>
46              
47             =head1 AUTHOR
48              
49             Guillermo Roditi (groditi) E<lt>groditi@cpan.orgE<gt>
50              
51             =head1 COPYRIGHT AND LICENSE
52              
53             This software is copyright (c) 2009 by Guillermo Roditi.
54              
55             This is free software; you can redistribute it and/or modify it under
56             the same terms as the Perl 5 programming language system itself.
57              
58             =cut