| 1 | package Build::PPK::Deptool::Util; | ||
| 2 | |||
| 3 | # Copyright (c) 2018, cPanel, L.L.C. | ||
| 4 | # All rights reserved. | ||
| 5 | # http://cpanel.net/ | ||
| 6 | # | ||
| 7 | # This is free software; you can redistribute it and/or modify it under the same | ||
| 8 | # terms as Perl itself. See the LICENSE file for further details. | ||
| 9 | |||
| 10 | use strict; | ||
| 11 | use warnings; | ||
| 12 | |||
| 13 | use File::Find (); | ||
| 14 | |||
| 15 | sub older_than { | ||
| 16 | my ( $class, $a, $b ) = map { ( stat $_ )[9] } @_; | ||
| 17 | |||
| 18 | return 1 if $a < $b; | ||
| 19 | return 0; | ||
| 20 | } | ||
| 21 | |||
| 22 | sub recursive_delete { | ||
| 23 | my ( $class, @items ) = @_; | ||
| 24 | |||
| 25 | File::Find::finddepth( | ||
| 26 | { | ||
| 27 | 'no_chdir' => 1, | ||
| 28 | 'wanted' => sub { | ||
| 29 | if ( -d $File::Find::name ) { | ||
| 30 | rmdir $File::Find::name; | ||
| 31 | } | ||
| 32 | else { | ||
| 33 | unlink $File::Find::name; | ||
| 34 | } | ||
| 35 | } | ||
| 36 | }, | ||
| 37 | @items | ||
| 38 | ); | ||
| 39 | } | ||
| 40 | |||
| 41 | 1; |