File Coverage

blib/lib/Comparer/file_size.pm
Criterion Covered Total %
statement 8 16 50.0
branch 0 6 0.0
condition 0 2 0.0
subroutine 3 6 50.0
pod 0 2 0.0
total 11 32 34.3


line stmt bran cond sub pod time code
1             package Comparer::file_size;
2              
3 1     1   410406 use 5.010001;
  1         5  
4 1     1   7 use strict 'subs', 'vars';
  1         2  
  1         54  
5 1     1   7 use warnings;
  1         2  
  1         403  
6              
7             our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
8             our $DATE = '2024-11-10'; # DATE
9             our $DIST = 'Comparer-file_size'; # DIST
10             our $VERSION = '0.001'; # VERSION
11              
12             sub meta {
13             return +{
14 0     0 0   v => 1,
15             args => {
16             follow_symlink => {schema=>'bool*', default=>1},
17             reverse => {schema => 'bool*'},
18             },
19             };
20             }
21              
22             sub gen_comparer {
23 0     0 0   my %args = @_;
24              
25 0   0       my $follow_symlink = $args{follow_symlink} // 1;
26 0           my $reverse = $args{reverse};
27              
28             sub {
29 0 0   0     my @st1 = $follow_symlink ? stat($_[0]) : lstat($_[0]);
30 0 0         my @st2 = $follow_symlink ? stat($_[1]) : lstat($_[1]);
31              
32             (
33 0 0         $st1[7] <=> $st2[7]
34             ) * ($reverse ? -1 : 1)
35 0           };
36             }
37              
38             1;
39             # ABSTRACT: Compare file's size
40              
41             __END__