From f89e053f3e3a6f0f73a9ce2c8dd2c72db93d44bb Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Thu, 3 Nov 2016 03:38:44 +0100 Subject: Dpkg::Dist::Files: Add new load_dir method This method scans all fragment files inside a directory and loads each of them. --- scripts/Dpkg/Dist/Files.pm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'scripts/Dpkg/Dist') diff --git a/scripts/Dpkg/Dist/Files.pm b/scripts/Dpkg/Dist/Files.pm index c5d5fb0e1..2c4ab53ce 100644 --- a/scripts/Dpkg/Dist/Files.pm +++ b/scripts/Dpkg/Dist/Files.pm @@ -20,6 +20,8 @@ use warnings; our $VERSION = '0.01'; +use IO::Dir; + use Dpkg::Gettext; use Dpkg::ErrorHandling; @@ -101,6 +103,19 @@ sub parse { return $count; } +sub load_dir { + my ($self, $dir) = @_; + + my $count = 0; + my $dh = IO::Dir->new($dir) or syserr(g_('cannot open directory %s'), $dir); + + while (defined(my $file = $dh->read)) { + $count += $self->load("$dir/$file"); + } + + return $count; +} + sub get_files { my $self = shift; -- cgit v1.2.3