/** * ディレクトリごとコピー * * サブディレクトリ、含まれるファイルも全てコピーする * * <code> * #./test以下を./backup/testにコピー * File::copyDir('./test','./backup/test'); * </code> * * @param string $source コピー元 (ディレクトリ名) * @param string $dest コピー先 (ディレクトリ名) * @param bool $overwrite 上書きするか * @param mixed $ignore 無視するファイル名のリスト (.svnを指定するとSubVersionを無視) * @param mixed $hook_func ファイル、ディレクトリを作成した時にhookする関数名 (call_user_func 形式の引数) */ public static function copyDir($source, $dest, $overwrite = false, $ignore = array(), $hook_func = '') { $source = rtrim($source, '\\/'); $dest = rtrim($dest, '\\/'); if (!is_array($ignore)) { $ignore = array($ignore); } if (!is_dir($dest)) { File::buildMakeDir($dest, $hook_func); } chmod($dest, 0755); if ($handle = opendir($source)) { while (false !== ($file = readdir($handle))) { if ($file != '.' && $file != '..' && !in_array($file, $ignore)) { $path = $source . '/' . $file; if (is_file($path)) { if (!($ovr = is_file($dest . '/' . $file)) || $overwrite) { if (!@copy($path, $dest . '/' . $file)) { ECF::error($path . 'はコピーできません。パーミッションが適切に設定されていない可能性があります'); } } if ($hook_func) { call_user_func($hook_func, 'make_file', $dest . '/' . $file, $ovr); } } elseif (is_dir($path)) { if (!is_dir($dest . '/' . $file)) { File::buildMakeDir($dest . '/' . $file, $hook_func); //サブディレクトリを作成 } chmod($dest . '/' . $file, 0755); File::copyDir($path, $dest . '/' . $file, $overwrite, $ignore, $hook_func); //再帰呼び出し } } } closedir($handle); } }
File::buildPutFile($dir_output . '/' . $filepath, $source); if ($is_js and !$is_nolint) { //lint check $lint_error = jslint($pathname); if ($lint_error) { foreach ($lint_error as $lerr) { $phest->add('jslint', $basename . ':' . $lerr); } } } } } else { $outputpath = $dir_output . '/' . $filepath; $tmp_dir = dirname($outputpath); if (!is_dir($tmp_dir)) { File::buildMakeDir($tmp_dir); } copy($pathname, $outputpath); } if ($create_option) { $create_option = ' <code>' . trim($create_option) . '</code>'; } $subsection_key = 'etc'; if (isset($create_subsection_pattern[$last_extension])) { $subsection_key = $create_subsection_pattern[$last_extension]; } $anchortext = ''; if ($subsection_key == 'image') { $anchortext = '<img src="' . $home_local . '/' . $filepath . '" style="width:30px;height:30px;" /> ' . $filepath; } else { $anchortext = $filepath;