Commit e33ab11c authored by Michael Pyne's avatar Michael Pyne

util: Remove redundant directory empty checking code.

parent 6403bcc9
......@@ -143,23 +143,6 @@ sub _clone
return;
}
sub _isDirectoryEmpty
{
my $dir = shift;
# Empty returns are OK -- they are automatically the 'false' equivalent for
# whatever context the function is called in.
opendir (my $dh, $dir) or return;
if (any { $_ ne '.' && $_ ne '..' } [readdir($dh)]) {
close $dh;
return;
}
close $dh;
return 1;
}
# Either performs the initial checkout or updates the current git checkout
# for git-using modules, as appropriate.
#
......@@ -178,7 +161,7 @@ sub updateCheckout
}
else {
# Check if an existing source directory is there somehow.
if (-e "$srcdir" && !_isDirectoryEmpty($srcdir)) {
if (-e "$srcdir" && !is_dir_empty($srcdir)) {
if ($module->getOption('#delete-my-patches')) {
warning ("\tRemoving conflicting source directory " .
"as allowed by --delete-my-patches");
......
package ksb::Util;
package ksb::Util 0.20;
# Useful utilities, which are exported into the calling module's namespace by default.
......@@ -6,8 +6,6 @@ use 5.014; # Needed for state keyword
use strict;
use warnings;
our $VERSION = '0.10';
use Carp qw(cluck);
use Scalar::Util qw(blessed);
use File::Path qw(make_path);
......@@ -749,14 +747,14 @@ sub is_dir_empty
{
my $dir = shift;
opendir my $dirh, $dir or croak_runtime("Dir $dir doesn't exist when checking if empty");
opendir my $dirh, $dir or return;
# while-readdir needs Perl 5.12
while (readdir $dirh) {
next if ($_ eq '.' || $_ eq '..');
closedir ($dirh);
return 0; # not empty
return; # not empty
}
closedir ($dirh);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment