| 1 | package App::MacVictimUtils; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | our $DATE = '2021-05-25'; # DATE | |||||||||||||||||||||||||||
| 4 | 1 | our $VERSION = '0.002'; # VERSION | |||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use 5.010001; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Log::ger; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 1 | our %SPEC; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | $SPEC{delete_ds_store} = { | ||||||||||||||||||||||||||||
| 14 | 1 | v => 1.1, | |||||||||||||||||||||||||||
| 15 | summary => 'Recursively delete .DS_Store files', | ||||||||||||||||||||||||||||
| 16 | args => { | ||||||||||||||||||||||||||||
| 17 | dirs => { | ||||||||||||||||||||||||||||
| 18 | schema => ['array*', of=>'dirname*'], | ||||||||||||||||||||||||||||
| 19 | pos => 0, | ||||||||||||||||||||||||||||
| 20 | greedy => 1, | ||||||||||||||||||||||||||||
| 21 | }, | ||||||||||||||||||||||||||||
| 22 | }, | ||||||||||||||||||||||||||||
| 23 | features => { | ||||||||||||||||||||||||||||
| 24 | dry_run => 1, | ||||||||||||||||||||||||||||
| 25 | }, | ||||||||||||||||||||||||||||
| 26 | }; | ||||||||||||||||||||||||||||
| 27 | 0 | ▶ | sub delete_ds_store { | ||||||||||||||||||||||||||
|
Subroutine
delete_ds_store: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 28 | 0 | require File::Find; | |||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 0 | my %args = @_; | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 0 | ▶ | my @dirs = @{ $args{dirs} || ["."] }; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args{'dirs'} || ['.']
MC/DC0%0/1
$args{'dirs'} || ['.']
$args{'dirs'}
Truth table0%0/2
A
A= $args{'dirs'}
| |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | File::Find::find( | ||||||||||||||||||||||||||||
| 35 | 0 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 36 | 0 | ▶ | return unless -f && $_ eq '.DS_Store'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-f $_ and $_ eq ".DS_Store"
MC/DC0%0/2
-f $_ and $_ eq ".DS_Store"
-f $_
$_ eq ".DS_Store"
Truth table0%0/3
A and B
A= -f $_B= $_ eq ".DS_Store"
| |||||||||||||||||||||||||||||
| 37 | 0 | ▶ | if ($args{-dry_run}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | 0 | log_info("[DRY] Deleting %s/.DS_Store ...", $File::Find::dir); | |||||||||||||||||||||||||||
| 39 | 0 | return; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | 0 | log_info("Deleting %s/.DS_Store ...", $File::Find::dir); | |||||||||||||||||||||||||||
| 42 | 0 | ▶ | unlink $_ or do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | 0 | log_warn("Can't delete %s/.DS_Store: %s", $File::Find::dir, $!); | |||||||||||||||||||||||||||
| 44 | }; | ||||||||||||||||||||||||||||
| 45 | }, | ||||||||||||||||||||||||||||
| 46 | 0 | @dirs, | |||||||||||||||||||||||||||
| 47 | ); | ||||||||||||||||||||||||||||
| 48 | 0 | [200]; | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 1 | 1; | |||||||||||||||||||||||||||
| 52 | # ABSTRACT: CLI utilities for when dealing with Mac computers/files | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | __END__ | ||||||||||||||||||||||||||||