本文整理汇总了PHP中FileHandler::DeleteDirRecursive方法的典型用法代码示例。如果您正苦于以下问题:PHP FileHandler::DeleteDirRecursive方法的具体用法?PHP FileHandler::DeleteDirRecursive怎么用?PHP FileHandler::DeleteDirRecursive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileHandler
的用法示例。
在下文中一共展示了FileHandler::DeleteDirRecursive方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: apiRejudge
/**
* Re-sends a problem to Grader.
*
* @param Request $r
* @throws InvalidDatabaseOperationException
*/
public static function apiRejudge(Request $r)
{
// Init
self::initializeGrader();
// Get the user who is calling this API
self::authenticateRequest($r);
self::validateDetailsRequest($r);
if (!Authorization::CanEditRun($r['current_user_id'], $r['run'])) {
throw new ForbiddenAccessException('userNotAllowed');
}
self::$log->info('Run being rejudged!!');
// Try to delete existing directory, if exists.
try {
$grade_dir = RunController::getGradePath($r['run']);
FileHandler::DeleteDirRecursive($grade_dir);
} catch (Exception $e) {
// Soft error :P
self::$log->warn($e);
}
try {
self::$grader->Grade([$r['run']->guid], true, $r['debug'] || false);
} catch (Exception $e) {
self::$log->error('Call to Grader::grade() failed:');
self::$log->error($e);
}
$response = array();
$response['status'] = 'ok';
self::invalidateCacheOnRejudge($r['run']);
// Expire ranks
UserController::deleteProblemsSolvedRankCacheList();
return $response;
}
示例2: ZipArchive
$zip = new ZipArchive();
$zip->open("{$dirname}/interactive.zip", ZipArchive::CREATE | ZipArchive::OVERWRITE);
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dirname), RecursiveIteratorIterator::LEAVES_ONLY);
foreach ($files as $name => $file) {
if ($file->isDir()) {
continue;
}
if ($file->getFilename() == 'interactive.zip') {
continue;
}
$filePath = $file->getRealPath();
$relativePath = substr($filePath, strlen($dirname) + 1);
// Add current file to archive
$zip->addFile($filePath, $relativePath);
}
$zip->close();
header('Content-Type: application/zip');
header("Content-Disposition: attachment; filename={$_POST['name']}.zip");
readfile("{$dirname}/interactive.zip");
FileHandler::DeleteDirRecursive($dirname);
die;
}
}
} catch (Exception $e) {
$smarty->assign('error', $e);
} finally {
FileHandler::DeleteDirRecursive($dirname);
}
}
}
$smarty->display('../../../templates/libinteractive.gen.tpl');
示例3: cleanup
public function cleanup()
{
if ($this->tmpDir != null && is_dir($this->tmpDir)) {
FileHandler::DeleteDirRecursive($this->tmpDir);
}
// Something went wrong and the target directory was not committed. Rollback.
if ($this->created && !file_exists($this->targetDir)) {
FileHandler::DeleteDirRecursive($this->gitDir);
}
}
示例4: CleanPath
static function CleanPath($path)
{
FileHandler::DeleteDirRecursive($path);
mkdir($path, 0755, true);
}