diff options
author | Guillem Jover <guillem@debian.org> | 2016-11-03 03:38:44 +0100 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2016-11-03 06:03:35 +0100 |
commit | f89e053f3e3a6f0f73a9ce2c8dd2c72db93d44bb (patch) | |
tree | a39dd58eadbd556af0d09b8dda5ba4662a012df1 /scripts/Dpkg/Dist/Files.pm | |
parent | 2aa7752b0069188cc692fd71db6a680d94bc1765 (diff) | |
download | dpkg-f89e053f3e3a6f0f73a9ce2c8dd2c72db93d44bb.tar.gz |
Dpkg::Dist::Files: Add new load_dir method
This method scans all fragment files inside a directory and loads
each of them.
Diffstat (limited to 'scripts/Dpkg/Dist/Files.pm')
-rw-r--r-- | scripts/Dpkg/Dist/Files.pm | 15 |
1 files changed, 15 insertions, 0 deletions
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; |