Changeset 16436

Show
Ignore:
Timestamp:
16.07.2008 17:04:14 (11 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.

Files:
1 modified

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;