protected function _clearPath($path, $themes, $targets)
{
if (!file_exists($path)) {
return;
}
$dir = new DirectoryIterator($path);
foreach ($dir as $file) {
$name = $base = $file->getFilename();
if (in_array($name, ['.', '..'])) {
continue;
}
// timestamped files.
if (preg_match('/^(.*)\\.v\\d+(\\.[a-z]+)$/', $name, $matches)) {
$base = $matches[1] . $matches[2];
}
// themed files
foreach ($themes as $theme) {
if (strpos($base, $theme) === 0 && strpos($base, '-') !== false) {
list($themePrefix, $base) = explode('-', $base);
}
}
if (in_array($base, $targets)) {
$this->_io->verbose(' - Deleting ' . $path . $name);
unlink($path . $name);
continue;
}
}
}