5
0
mirror of git://git.proxmox.com/git/pve-common.git synced 2025-01-09 05:17:35 +03:00

moved dir_glob_regex() and dir_glob_foreach() from PVE::Storage

This commit is contained in:
Dietmar Maurer 2012-03-28 07:58:05 +02:00
parent 66bda4e09d
commit 7eb283fbd2
3 changed files with 41 additions and 1 deletions

View File

@ -1,7 +1,7 @@
RELEASE=2.0
VERSION=1.0
PKGREL=22
PKGREL=23
PACKAGE=libpve-common-perl

View File

@ -7,6 +7,7 @@ use IO::Select;
use File::Basename;
use File::Path qw(make_path);
use IO::File;
use IO::Dir;
use IPC::Open3;
use Fcntl qw(:DEFAULT :flock);
use base 'Exporter';
@ -22,6 +23,8 @@ run_command
file_set_contents
file_get_contents
file_read_firstline
dir_glob_regex
dir_glob_foreach
split_list
template_replace
safe_print
@ -826,4 +829,34 @@ sub dump_logfile {
return ($count, $lines);
}
sub dir_glob_regex {
my ($dir, $regex) = @_;
my $dh = IO::Dir->new ($dir);
return wantarray ? () : undef if !$dh;
while (defined(my $tmp = $dh->read)) {
if (my @res = $tmp =~ m/^($regex)$/) {
$dh->close;
return wantarray ? @res : $tmp;
}
}
$dh->close;
return wantarray ? () : undef;
}
sub dir_glob_foreach {
my ($dir, $regex, $func) = @_;
my $dh = IO::Dir->new ($dir);
if (defined $dh) {
while (defined(my $tmp = $dh->read)) {
if (my @res = $tmp =~ m/^($regex)$/) {
&$func (@res);
}
}
}
}
1;

7
debian/changelog vendored
View File

@ -1,3 +1,10 @@
libpve-common-perl (1.0-23) unstable; urgency=low
* moved dir_glob_regex() and dir_glob_foreach() from PVE::Storage
to PVE::Tools
-- Proxmox Support Team <support@proxmox.com> Wed, 28 Mar 2012 07:56:49 +0200
libpve-common-perl (1.0-22) unstable; urgency=low
* return number of sockets in read_cpuinfo