当前位置: 首页>>代码示例>>PHP>>正文


PHP FileHandler::BackupDir方法代码示例

本文整理汇总了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);
     }
 }
开发者ID:kukogit,项目名称:omegaup,代码行数:24,代码来源:FileHandler.php

示例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);
     }
 }
开发者ID:RicardoMelgoza,项目名称:omegaup,代码行数:45,代码来源:ProblemDeployer.php


注:本文中的FileHandler::BackupDir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。