本文整理汇总了PHP中FileHandler::BackupDir方法的典型用法代码示例。如果您正苦于以下问题:PHP FileHandler::BackupDir方法的具体用法?PHP FileHandler::BackupDir怎么用?PHP FileHandler::BackupDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileHandler
的用法示例。
在下文中一共展示了FileHandler::BackupDir方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: BackupDir
static function BackupDir($source, $dest)
{
if (!is_dir($source)) {
return;
}
if (!is_dir($dest)) {
@mkdir($dest, 0755);
}
if ($handle = opendir($source)) {
while (false !== ($entry = readdir($handle))) {
if ($entry == "." || $entry == "..") {
continue;
}
$sourcePath = "{$source}/{$entry}";
$targetPath = "{$dest}/{$entry}";
if (is_dir($sourcePath)) {
FileHandler::BackupDir($sourcePath, $targetPath);
} else {
link($sourcePath, $targetPath);
}
}
closedir($handle);
}
}
示例2: commit
public function commit($message, $user)
{
$this->git('add .', $this->tmpDir);
$this->requiresRejudge = false;
$changedFiles = false;
foreach (explode('\\n', $this->git('status -s --porcelain', $this->tmpDir)) as $line) {
if ($line == '') {
// Happens when the input is empty.
continue;
}
$changedFiles = true;
$path = substr($line, 3);
if (strpos($path, '.git') === 0 || strpos($path, 'statements/') === 0 || strpos($path, 'examples/') === 0 || strpos($path, 'interactive/examples/') === 0) {
continue;
}
$this->requiresRejudge = true;
}
if (!$changedFiles) {
// No changes detected. Return happily.
$this->log->debug('No files changed.');
return;
} elseif ($this->requiresRejudge) {
$this->log->debug('Files changed, rejudge required.');
} else {
$this->log->debug('Files changed.');
}
$this->git('config user.email ' . escapeshellarg("{$user->username}@omegaup"), $this->tmpDir);
$this->git('config user.name ' . escapeshellarg($user->username), $this->tmpDir);
$this->git('config push.default matching', $this->tmpDir);
$this->git('commit -am ' . escapeshellarg($message), $this->tmpDir);
$this->git('push origin master', $this->tmpDir);
if (!file_exists($this->targetDir . DIRECTORY_SEPARATOR . '.git')) {
$this->git('clone ' . escapeshellarg($this->gitDir) . ' ' . escapeshellarg($this->targetDir), PROBLEMS_PATH);
} else {
$this->git('pull --rebase', $this->targetDir);
}
// Copy the libinteractive templates to a publically accessible location.
$publicDestination = TEMPLATES_PATH . "/{$this->alias}/";
if (is_dir($publicDestination)) {
FileHandler::DeleteDirRecursive($publicDestination);
}
if (is_dir("{$this->tmpDir}/interactive/generated")) {
FileHandler::BackupDir("{$this->tmpDir}/interactive/generated", $publicDestination);
}
}