private function remove_old($src, $archive) { if (!is_dir($archive)) { return; } if (!(file_exists($src) && is_dir($src))) { log::info('emboss', "Removing directory {$src}"); emboss::rmdir_recursive($archive); return; } if (!($dh = opendir($archive))) { emboss::error("Failed to open {$archive} for reading"); return; } while ($file = readdir($dh)) { if ($file == '.' || $file == '..') { continue; } $srcpath = $src . '/' . $file; $archivepath = $archive . '/' . $file; if (is_dir($archivepath)) { emboss::remove_old($srcpath, $archivepath); } else { if (!file_exists($srcpath)) { log::info('emboss', "Removing {$file} from {$archive}"); if (!@unlink($archivepath)) { emboss::error("Failed to remove {$file} from {$archive}"); } } } } closedir($dh); }