The function makes sure that the path (directory and/or file) passed to it as an Input parameter is empty or not.
use constant SUCCESS => 1;
use constant FAILURE => 0;
sub fint_isnot_empty ($)
{
#Arguments: The path to be checked.
my($mstr_path) = @_;
my $mint_retval = SUCCESS; #This holds the return value
#if the path is a file then the size should be checked else if
# its a directory,
#the number of elements within should be checked.
$mint_retval = FAILURE if (-f $mstr_path and -z $mstr_path);
if (-d $mstr_path)
{
opendir(HNDLDIR,$mstr_path);
my @marr_path_files = readdir(HNDLDIR);
close(HNDLDIR);
#even if the dir is empty, because of . and .. the
#count will be atleast 1.
$mint_retval = FAILURE if ($#marr_path_files lt 2);
}
#If there is no path existing as specified, setup to return
#failure.
$mint_retval = FAILURE if (! -e $mstr_path);
return $mint_retval;
} # end of fint_isnot_empty

