Changeset 16436


Ignore:
Timestamp:
2008-07-16T17:04:14+12:00 (16 years ago)
Author:
ak19
Message:

Moved the utility subroutine is_dir_empty from gsConvert.pl into here in case it may come in handy in other situations.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/perllib/util.pm

    r16404 r16436  
    927927
    928928
     929# A method to check if a directory is empty (note that an empty directory still has non-zero size!!!)
     930# Code is from http://episteme.arstechnica.com/eve/forums/a/tpc/f/6330927813/m/436007700831
     931sub is_dir_empty
     932{
     933    my ($path) = @_;
     934    opendir DIR, $path;
     935    while(my $entry = readdir DIR) {
     936        next if($entry =~ /^\.\.?$/);
     937        closedir DIR;
     938        return 0;
     939    }
     940    closedir DIR;
     941    return 1;
     942}
     943
    9299441;
Note: See TracChangeset for help on using the changeset viewer.