UpdateModel::findFiles PHP Method

findFiles() public static method

Find a list of filenames in a folder or zip.
public static findFiles ( string $path, array $fileNames ) : array
$path string Folder or zip file to look in.
$fileNames array List of files to attempt to locate inside $path.
return array
    public static function findFiles($path, $fileNames)
    {
        // Get the list of potential files to analyze.
        if (is_dir($path)) {
            $entries = self::getInfoFiles($path, $fileNames);
        } else {
            $entries = self::getInfoZip($path, $fileNames);
        }
        return $entries;
    }

Usage Example

 /**
  * Parse an addon's README file.
  *
  * @param string $Path The base path to search from.
  * @return string
  */
 protected function parseReadme($Path)
 {
     $ReadmePaths = array('/readme', '/README', '/readme.md', '/README.md', '/readme.txt', '/README.txt');
     $Description = '';
     // Get the list of potential files to analyze.
     $Entries = UpdateModel::findFiles($Path, $ReadmePaths);
     if ($Entries === false) {
         return '';
     }
     foreach ($Entries as $Entry) {
         $ReadMeContents = file_get_contents($Entry['Path']);
         $Description = Gdn_Format::markdown($ReadMeContents);
     }
     $FolderPath = substr($Path, 0, -4);
     Gdn_FileSystem::removeFolder($FolderPath);
     return $Description;
 }