public function install($theme_zip_file, $sandbox, $redirect = false) { if ($this->extractTheme($theme_zip_file, $sandbox)) { if ($theme_directory = $this->installTheme(self::UPLOADED_THEME_DIR_NAME, $sandbox, $redirect)) { FilesHelper::removeDir($sandbox); // To catch permission exceptions //Tools::deleteDirectory($sandbox); return true; } } return false; }
public function complete() { ProviderLog::start('Chunk complete'); $content = ''; for ($i = 1, $count = (int) $this->_lastChunk['total']; $i <= $count; $i++) { if (!file_exists($this->_chunkFolder . "/{$i}")) { trigger_error('Missing chunk #' . $i . ' : ' . implode(' / ', scandir($this->_chunkFolder)), E_USER_NOTICE); } $data = FilesHelper::readFile($this->_chunkFolder . "/{$i}"); if (!empty($this->_lastChunk['encode'])) { $data = base64_decode($data); } $content .= $data; } FilesHelper::removeDir($this->_chunkFolder); $content = empty($this->_lastChunk['encode']) ? $content : rawurldecode($content); ProviderLog::end('Chunk complete'); return $content; }
public static function removeDir($dir, $self = true) { try { $objects = scandir($dir); foreach ($objects as $object) { if ($object != '.' && $object != '..') { if (strtolower(filetype($dir . '/' . $object)) == 'dir') { FilesHelper::removeDir($dir . '/' . $object); } else { FilesHelper::deleteFile($dir . '/' . $object); } } } reset($objects); if ($self) { FilesHelper::deleteFolder($dir); } } catch (Exception $e) { throw new PermissionsException('Unable to remove the directory: ' . $dir); } }
function clearDirs($base_path, $dirs, $self = true) { foreach ($dirs as $dir) { FilesHelper::removeDir($base_path . '/' . $dir, $self); } }
function moveInnerPreview($themeName) { $themeDir = FilesHelper::normalizePath(getThemeDir($themeName)); $inner_preview_dir = $themeDir . '/' . $themeName . _PREVIEW_SUFFIX_; if (file_exists($inner_preview_dir)) { $previewThemeName = $themeName . _PREVIEW_SUFFIX_; $previewThemeDir = FilesHelper::normalizePath(getThemeDir($previewThemeName)); if (is_dir($previewThemeDir)) { FilesHelper::removeDir($previewThemeDir); } rename($inner_preview_dir, $previewThemeDir); } }
public function chunkClear() { $chunk = new Chunk(); FilesHelper::removeDir($chunk->UPLOAD_PATH); }