Commits

Palmer, 2E0EOL  committed a19df94

First crack at Scan() function

  • Participants
  • Parent commits 2fb73a6
  • Branches develop

Comments (0)

Files changed (1)

 	return $self;
 }
 #----------------------------------------------------------------------------
+sub Scan($@)
+{
+	my ( $self, %Params ) = @_;
+
+	if ( opendir(my $d, $Params{'Dir'}) ) {
+		my @entries = ( );
+		while ( my $ent = readdir($d) ) { push(@entries, $ent) }
+		closedir($d); # Get the handle out of the way before recursion.
+
+		foreach my $ent ( @entries ) {
+			my $fullPath = sprintf('%s/%s', $Params{'Dir'}, $ent);
+			if ( -d $fullPath ) {
+				if ( $Params{'Recurse'} ) {
+					my %newParams = %Params;
+					$newParams{'Dir'} = $fullPath;
+					$self->Scan(%newParams);
+				} else { next; } # Skip directories where not recursing
+			} else {
+				$self->_ProcessFile($fullPath);
+			}
+		}
+	}
+}
 #----------------------------------------------------------------------------
 #----------------------------------------------------------------------------
 package main;