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


PHP copyDir函数代码示例

本文整理汇总了PHP中copyDir函数的典型用法代码示例。如果您正苦于以下问题:PHP copyDir函数的具体用法?PHP copyDir怎么用?PHP copyDir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了copyDir函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: copyDir

/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 15-7-11
 * Time: 上午10:40
 */
function copyDir($dirSrc, $dirTo)
{
    if (is_file($dirTo)) {
        //如果目标不是一个目录则退出
        echo "目标不是目录不能创建!!";
        return;
    }
    if (!file_exists($dirTo)) {
        //如果目标不存在,则创建目录
        mkdir($dirTo);
    }
    if ($dir_handle = @opendir($dirSrc)) {
        //打开目录并判断是否成功
        while ($filename = readdir($dir_handle)) {
            //循环遍历目录
            if ($filename != "." && $filename != "..") {
                //排除两个特殊目录
                $subSrcFile = $dirSrc . "/" . $filename;
                $subToFile = $dirTo . "/" . $filename;
                if (is_dir($subSrcFile)) {
                    //如果是子目录,则递归
                    copyDir($subSrcFile, $subToFile);
                }
                if (is_file($subSrcFile)) {
                    //如果是文件,则使用copy直接拷贝
                    copy($subSrcFile, $subToFile);
                }
            }
        }
        closedir($dir_handle);
        //最后记得一定要关闭目录句柄
    }
}
开发者ID:skyler2tao,项目名称:languageStudy,代码行数:39,代码来源:copyDir.php

示例2: copyDir

function copyDir($source, $target, $exclude = array())
{
    if (is_dir($source)) {
        @mkdir($target, 0777, true);
        $dirRef = dir($source);
        while (FALSE !== ($entry = $dirRef->read())) {
            // Read through exclude list. If the current directory is on it, skip it
            $skip = false;
            foreach ($exclude as $exclFile) {
                if ($entry == $exclFile) {
                    $skip = true;
                    continue;
                }
            }
            if ($entry == '.' || $entry == '..' || $skip) {
                continue;
            }
            $entryFullPath = $source . '/' . $entry;
            if (is_dir($entryFullPath)) {
                copyDir($entryFullPath, $target . '/' . $entry, $exclude);
                continue;
            }
            copy($entryFullPath, $target . '/' . $entry);
            echo "Copying " . $entry . " to " . $target . "/\n";
        }
        $dirRef->close();
    } else {
        copy($source, $target);
    }
}
开发者ID:mray,项目名称:terminal-overload,代码行数:30,代码来源:newProject.php

示例3: exportBuildFiles

function exportBuildFiles($configArray)
{
    global $modx;
    $dirPermission = $modx->getOption('dirPermission', $configArray, 0777);
    $packageNameLower = $modx->getOption('packageNameLower', $configArray, '');
    $targetRoot = $modx->getOption('targetRoot', $configArray, '');
    $workingDir = $modx->getOption('core_path') . 'components/migxelementsmanager/_buildsources/';
    if (!empty($packageNameLower) && !empty($workingDir) && !empty($targetRoot)) {
        $targetDir = $targetRoot . '_build/';
        copyDir($workingDir, $targetDir, $dirPermission);
        //overwrite from package
        $workingDir = $modx->getOption('core_path') . 'components/' . $packageNameLower . '/_buildsources/';
        copyDir($workingDir, $targetDir, $dirPermission);
    }
}
开发者ID:ksneo,项目名称:migxElementsManager,代码行数:15,代码来源:preparebuild.php

示例4: copyDir

function copyDir($src, $dst)
{
    // 原目录,复制到的目录
    $dir = opendir($src);
    @mkdir($dst);
    while (false !== ($file = readdir($dir))) {
        if ($file != '.' && $file != '..') {
            if (is_dir($src . '/' . $file)) {
                copyDir($src . '/' . $file, $dst . '/' . $file);
            } else {
                copy($src . '/' . $file, $dst . '/' . $file);
            }
        }
    }
    closedir($dir);
}
开发者ID:leifuchen0111,项目名称:company,代码行数:16,代码来源:function.php

示例5: copyDir

function copyDir($path, $newPath)
{
    $items = listDirectory($path);
    if (!is_dir($newPath)) {
        mkdir($newPath, octdec(DIRPERMISSIONS));
    }
    foreach ($items as $item) {
        if ($item == '.' || $item == '..') {
            continue;
        }
        $oldPath = RoxyFile::FixPath($path . '/' . $item);
        $tmpNewPath = RoxyFile::FixPath($newPath . '/' . $item);
        if (is_file($oldPath)) {
            copy($oldPath, $tmpNewPath);
        } elseif (is_dir($oldPath)) {
            copyDir($oldPath, $tmpNewPath);
        }
    }
}
开发者ID:fzlrhmn,项目名称:sanitasi-salatiga,代码行数:19,代码来源:copydir.php

示例6: exec

 public function exec()
 {
     try {
         /* check specified directory */
         chkRequireConts($this->getPrm());
         $desc = yaml_parse_file($this->getPrm() . 'conf/desc.yml');
         if (false === $desc) {
             throw new \err\ComErr('could not read module description file', 'please check ' . $tgt . 'conf/desc.yml');
         }
         /* check installed module */
         if (true === isInstalled($desc['name'])) {
             /* target module is already installed */
             throw new \err\ComErr('specified module is already installed', 'please check \'spac mod list\'');
         }
         /* copy module contents */
         copyDir($this->getPrm(), __DIR__ . '/../../mod/' . $desc['name']);
         /* add module name to module config file */
         $modcnf = yaml_parse_file(__DIR__ . '/../../../../conf/module.yml');
         $first = false;
         if (null === $modcnf) {
             $first = true;
             $modcnf = array();
         }
         $add = array('name' => $desc['name'], 'select' => false);
         if (true === $first) {
             $add['select'] = true;
         }
         $modcnf[] = $add;
         if (false === copy(__DIR__ . '/../../../../conf/module.yml', __DIR__ . '/../../../../conf/module.yml_')) {
             throw new \err\ComErr('could not create backup of module config', 'please check ' . __DIR__ . '/../../../../conf');
         }
         if (false === file_put_contents(__DIR__ . '/../../../../conf/module.yml', yaml_emit($modcnf))) {
             throw new \err\ComErr('could not edit module config file', 'please check ' . __DIR__ . '/../../../../conf/module.yml');
         }
         unlink(__DIR__ . '/../../../../conf/module.yml_');
         echo 'Successful install ' . $desc['name'] . ' module' . PHP_EOL;
         echo 'You can check installed module \'spac mod list\',' . PHP_EOL;
     } catch (\Exception $e) {
         throw $e;
     }
 }
开发者ID:simpart,项目名称:trut,代码行数:41,代码来源:ModAdd.php

示例7: copyDir

function copyDir($source, $destination)
{
    if (is_dir($source)) {
        @mkdir($destination, 0755);
        $directory = dir($source);
        while (FALSE !== ($readdirectory = $directory->read())) {
            if ($readdirectory == '.' || $readdirectory == '..') {
                continue;
            }
            $PathDir = $source . '/' . $readdirectory;
            if (is_dir($PathDir)) {
                copyDir($PathDir, $destination . '/' . $readdirectory);
                continue;
            }
            copy($PathDir, $destination . '/' . $readdirectory);
        }
        $directory->close();
    } else {
        copy($source, $destination);
    }
}
开发者ID:itm-constantine,项目名称:ubrr_umi,代码行数:21,代码来源:index.php

示例8: copyDir

function copyDir($src, $dst)
{
    if (!file_exists($src)) {
        throw new \Exakat\Exceptions\NoSuchDir('Can\'t find dir : "' . $src . '"');
    }
    $dir = opendir($src);
    if (!$dir) {
        throw new \Exakat\Exceptions\NoSuchDir('Can\'t open dir : "' . $src . '"');
    }
    $total = 0;
    mkdir($dst, 0755);
    while (false !== ($file = readdir($dir))) {
        if ($file != '.' && $file != '..') {
            if (is_dir($src . '/' . $file)) {
                $total += copyDir($src . '/' . $file, $dst . '/' . $file);
            } else {
                copy($src . '/' . $file, $dst . '/' . $file);
                ++$total;
            }
        }
    }
    closedir($dir);
    return $total;
}
开发者ID:exakat,项目名称:exakat,代码行数:24,代码来源:helpers.php

示例9: copyDir

function copyDir($subject, $to)
{
    if (file_exists($to) || !mkdir($to)) {
        return refresh('Destination exists or creation of destination failed.');
    }
    $handle = opendir($subject);
    while (($dirItem = readdir($handle)) !== false) {
        if ($dirItem == '.' || $dirItem == '..') {
            continue;
        }
        $path = $subject . '/' . $dirItem;
        if (is_dir($path)) {
            copyDir($path, $to . '/' . $dirItem);
        } else {
            copy($path, $to . '/' . $dirItem);
        }
    }
    closedir($handle);
}
开发者ID:altunoren,项目名称:useful-php-scripts,代码行数:19,代码来源:Simple-PHP-file-browser-manager.php

示例10: copyDir

function copyDir($src, $desc)
{
    if (is_file($src)) {
        return copy($src, $desc);
    } else {
        if (is_dir($src)) {
            is_dir($desc) || mkdir($desc);
            $files = scandir($src);
            foreach ($files as $file) {
                if ($file == '.' || $file == '..') {
                    continue;
                }
                if (!copyDir($src . '/' . $file, $desc . "/" . $file)) {
                    return false;
                }
            }
            return true;
        }
    }
}
开发者ID:41835478,项目名称:GMU,代码行数:20,代码来源:index.php

示例11: copyDir

function copyDir($src, $dst)
{
    if (is_dir($src) === true) {
        $handle = opendir($src);
        while ($entry = readdir($handle)) {
            if ($entry === '.' || $entry === '..') {
                continue;
            }
            if (is_dir("{$src}/{$entry}")) {
                mkdir("{$dst}/{$entry}");
            }
            copyDir("{$src}/{$entry}", "{$dst}/{$entry}");
        }
        closedir($handle);
    } else {
        copy($src, $dst);
    }
}
开发者ID:nextben,项目名称:PVR_editor,代码行数:18,代码来源:_file.php

示例12: initFolder

 /**
  * Clear and init folder
  *
  * @return string
  */
 private function initFolder()
 {
     if ($this->finalName === null) {
         return "Can't produce Devoops format to stdout";
     }
     // Clean temporary destination
     if (file_exists($this->tmpName)) {
         rmdirRecursive($this->tmpName);
     }
     // Copy template
     copyDir($this->config->dir_root . '/media/devfaceted', $this->tmpName);
 }
开发者ID:exakat,项目名称:exakat,代码行数:17,代码来源:Ambassador.php

示例13: run

 public function run()
 {
     if ($this->config->project === 'default') {
         throw new ProjectNeeded();
     }
     $path = $this->config->projects_root . '/projects/' . $this->config->project;
     if (!file_exists($path)) {
         throw new NoSuchProject($this->config->project);
     }
     if (!file_exists($path . '/code')) {
         throw new NoCodeInProject($this->config->project);
     }
     switch (true) {
         // symlink case
         case $this->config->project_vcs === 'symlink':
             // Nothing to do, the symlink is here for that
             break;
             // copy case
         // copy case
         case $this->config->project_vcs === 'copy':
             // Remove and copy again
             $total = rmdirRecursive($this->config->projects_root . '/projects/' . $this->config->project . '/code/');
             display("{$total} files were removed");
             $total = copyDir(realpath($this->config->project_url), $this->config->projects_root . '/projects/' . $this->config->project . '/code');
             display("{$total} files were copied");
             break;
             // Git case
         // Git case
         case file_exists($path . '/code/.git'):
             display('Git pull for ' . $this->config->project);
             $res = shell_exec('cd ' . $path . '/code/; git branch | grep \\*');
             $branch = substr(trim($res), 2);
             $resInitial = shell_exec('cd ' . $path . '/code/; git show-ref --heads ' . $branch);
             $date = trim(shell_exec('cd ' . $path . '/code/; git pull --quiet; git log -1 --format=%cd '));
             $resFinal = shell_exec('cd ' . $path . '/code/; git show-ref --heads ' . $branch);
             if ($resFinal != $resInitial) {
                 display("Git updated to commit {$res} (Last commit : {$date})");
             } else {
                 display("No update available (Last commit : {$date})");
             }
             break;
             // svn case
         // svn case
         case file_exists($path . '/code/.svn'):
             display('SVN update ' . $this->config->project);
             $res = shell_exec('cd ' . $path . '/code/; svn update');
             preg_match('/At revision (\\d+)/', $res, $r);
             display("SVN updated to revision {$r['1']}");
             break;
             // bazaar case
         // bazaar case
         case file_exists($path . '/code/.bzr'):
             display('Bazaar update ' . $this->config->project);
             $res = shell_exec('cd ' . $path . '/code/; bzr update 2>&1');
             preg_match('/revision (\\d+)/', $res, $r);
             display("Bazaar updated to revision {$r['1']}");
             break;
             // composer case
         // composer case
         case $this->config->project_vcs === 'composer':
             display('Composer update ' . $this->config->project);
             $res = shell_exec('cd ' . $path . '/code/; composer install ');
             $json = file_get_contents($path . '/code/composer.lock');
             $json = json_decode($json);
             foreach ($json->packages as $package) {
                 if ($package->name == $this->config->project_url) {
                     display("Composer updated to revision " . $package->source->reference . ' ( version : ' . $package->version . ' )');
                 }
             }
             break;
         default:
             display('No VCS found to update (Only git, svn and bazaar are supported. Ask exakat to add more.');
     }
 }
开发者ID:exakat,项目名称:exakat,代码行数:74,代码来源:Update.php

示例14: copyDir

function copyDir($src, $dst)
{
    try {
        /* check source directory */
        if (false === isDirExists($src)) {
            throw new \Exception('could not find source directory');
        }
        /* check destination directory */
        if (false === isDirExists($dst)) {
            if (false === mkdir($dst)) {
                throw new \Exception('could not create destination directory');
            }
        }
        $scan = scandir($src);
        foreach ($scan as $elm) {
            if (0 === strcmp($elm, '.') || 0 === strcmp($elm, '..')) {
                continue;
            }
            $ftype = filetype($src . '/' . $elm);
            if (0 === strcmp($ftype, 'dir')) {
                copyDir($src . '/' . $elm, $dst . '/' . $elm);
            } else {
                if (false === copy($src . '/' . $elm, $dst . '/' . $elm)) {
                    throw new \Exception('could not copy \'' . $src . '/' . $elm . '\'' . ' to \'' . $dst . '\'');
                }
            }
        }
    } catch (\Exception $e) {
        throw $e;
    }
}
开发者ID:simpart,项目名称:trut,代码行数:31,代码来源:file.php

示例15: copy

 function copy($source, $destination)
 {
     append_to_log("Source: {$source}   Destination: {$destination}");
     ob_start();
     var_dump($_SERVER);
     $m = ob_get_contents();
     ob_end_clean();
     append_to_log($m);
     // Make real path to source and destination.
     $realSource = $_SERVER["DOCUMENT_ROOT"] . $source;
     $realDestination = $_SERVER["DOCUMENT_ROOT"] . $destination;
     append_to_log("RealSource: {$realSource}   RealDestination: {$realDestination}");
     $status = copyDir($realSource, $realDestination);
     if ($status) {
         append_to_log("copy was OK");
         return eZWebDAVServer::OK_CREATED;
     } else {
         append_to_log("copy FAILED");
         return eZWebDAVServer::FAILED_CONFLICT;
     }
 }
开发者ID:runelangseid,项目名称:ezpublish,代码行数:21,代码来源:ezwebdavfileserver.php


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