Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
Modified Scan to allow for requesting a specific extension.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelchisari authored and The Appleseed Project committed Mar 4, 2011
1 parent 5bc0b92 commit 68e9075
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions libraries/storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function Exists ( $pComponent, $pArea, $pDirectory, $pFilename ) {
return ( $return );
}

public function Scan ( $pDirectory ) {
public function Scan ( $pDirectory, $pExtension = null ) {
eval ( GLOBALS );

$Data = array();
Expand All @@ -80,7 +80,22 @@ public function Scan ( $pDirectory ) {
if ( $file == '.' ) continue;
if ( $file == '..' ) continue;

$return[] = $file;
// We're looking for a specific extension
if ( $pExtension ) {
// Remove any . to avoid confusion
$pExtension = str_replace ( '.', '', $pExtension );

// Search for . followed by extension at end of the line
$pattern = '/\.' . $pExtension . '$/';

// Match for the requested extension
if ( preg_match ( $pattern, $file ) ) {
$return[] = $file;
}
} else {
// Return the file no matter what type.
$return[] = $file;
}
}

return ( $return );
Expand Down

0 comments on commit 68e9075

Please sign in to comment.