コード例 #1
0
ファイル: DirectoryUtils.php プロジェクト: spiasecki/ubirimi
 /**
  * Copy a file, or recursively copy a folder and its contents
  *
  * @author      Aidan Lister <*****@*****.**>
  * @version     1.0.1
  * @link        http://aidanlister.com/repos/v/function.copyr.php
  * @param       string $source    Source path
  * @param       string $dest      Destination path
  * @return      bool     Returns TRUE on success, FALSE on failure
  */
 public static function copyr($source, $dest)
 {
     // Check for symlinks
     if (is_link($source)) {
         return symlink(readlink($source), $dest);
     }
     // Simple copy for a file
     if (is_file($source)) {
         return copy($source, $dest);
     }
     // Make destination directory
     if (!is_dir($dest)) {
         mkdir($dest);
     }
     // Loop through the folder
     $dir = dir($source);
     while (false !== ($entry = $dir->read())) {
         // Skip pointers
         if ($entry == '.' || $entry == '..') {
             continue;
         }
         // Deep copy directories
         DirectoryUtils::copyr("{$source}/{$entry}", "{$dest}/{$entry}");
     }
     // Clean up
     $dir->close();
     return true;
 }
コード例 #2
0
ファイル: SVNUtils.php プロジェクト: spiasecki/ubirimi
 /**
  * Create standard svn directories
  * /trunk
  * /tags
  * /branches
  *
  * @param string Path to create subversion
  */
 public static function createStandardDirectories($path)
 {
     $tmpdir = DirectoryUtils::getTmpDirectory();
     try {
         mkdir($tmpdir . DIRECTORY_SEPARATOR . "trunk");
         mkdir($tmpdir . DIRECTORY_SEPARATOR . "branches");
         mkdir($tmpdir . DIRECTORY_SEPARATOR . "tags");
         SVNUtils::_svnImport($path, $tmpdir);
     } catch (Exception $e) {
         DirectoryUtils::removeDirectory($path);
         DirectoryUtils::removeDirectory($tmpdir);
         throw $e;
     }
     DirectoryUtils::removeDirectory($tmpdir);
 }