use wcf\system\setup\Installer;
use wcf\system\template\SetupTemplateEngine;
use wcf\system\WCF;
+use wcf\util\DirectoryUtil;
use wcf\util\FileUtil;
use wcf\util\StringUtil;
use wcf\util\UserUtil;
WCF::getTPL()->display('stepInstallPackages');
// delete tmp files
- $directory = TMP_DIR.TMP_FILE_PREFIX.'/';
- $it = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($directory));
- while ($it->valid()) {
- // delete all files except directories and packages (required for post-wcfsetup installation)
- if (!$it->isDot() && !$it->isDir() && !preg_match('~\.tar(\.gz)?$~', $it->getSubPathName())) {
- @unlink($it->key());
- }
-
- $it->next();
- }
+ $directory = TMP_DIR.'/';
+ DirectoryUtil::getInstance($directory)->removePattern('~\.tar(\.gz)?$~', true);
}
/**
/**
* Removes all files that match the given pattern.
*
- * @param string $pattern pattern to match
+ * @param string $pattern pattern to match
+ * @param boolean $negativeMatch should the pattern be inversed
*/
- public function removePattern($pattern) {
+ public function removePattern($pattern, $negativeMatch = false) {
if (!$this->recursive) throw new SystemException('Removing of files only works in recursive mode');
- $files = $this->getFileObjects(self::SORT_NONE, $pattern);
+ $files = $this->getFileObjects(self::SORT_NONE, $pattern, $negativeMatch);
foreach ($files as $filename => $obj) {
if (!is_writable($obj->getPath())) {
}
if ($obj->isDir()) {
- rmdir($filename);
+ @rmdir($filename);
}
else if ($obj->isFile()) {
unlink($filename);