/** * Allows for deletion of non-empty directories - takes care of * recursion appropriately. * * @param string $strPath Full path to the folder to be deleted * * @return int number of deleted files */ public static function DeleteFolder($strPath) { if (!is_dir($strPath)) { unlink($strPath); return 1; } $d = dir($strPath); $count = 0; while ($entry = $d->read()) { if ($entry != "." && $entry != "..") { if (is_dir($strPath)) { $count += QFolder::DeleteFolder($strPath . "/" . $entry); } } } $d->close(); rmdir($strPath); return $count; }
private static function deleteFiles($strPluginName) { $strResult = "\r\nDeleting plugin files:\r\n"; $assetsPath = __DOCROOT__ . __PLUGIN_ASSETS__ . '/' . $strPluginName; if (file_exists($assetsPath)) { $deletedItems = QFolder::DeleteFolder($assetsPath); $strResult .= "- Deleted " . $deletedItems . " files from the plugin assets directory\r\n"; } else { $strResult .= "- Nothing was deleted from the plugin assets directory\r\n"; } $includesPath = __PLUGINS__ . '/' . $strPluginName; if (file_exists($includesPath)) { $deletedItems = QFolder::DeleteFolder($includesPath); $strResult .= "- Deleted " . $deletedItems . " files from the plugin includes directory\r\n"; } else { $strResult .= "- Nothing was deleted from the plugin includes directory\r\n"; } return $strResult; }
public static function cleanupExtractedFiles($strExtractedFolderName) { QFolder::DeleteFolder(__INCLUDES__ . self::PLUGIN_EXTRACTION_DIR . $strExtractedFolderName); return "\r\nCleaned up installation files.\r\n"; }