メインコンテンツまでスキップ
Version: Fegg 5.x

File::copyDirectory

ディレクトリの中身を別のディレクトリにコピーします

説明​

public bool File::copyDirectory( string $fromDirectory, string $toDirectory, [ boolean $recursiveCallFlag = false ] )

$fromDirectoryの下にあるファイルを$toDirectoryにコピーします。コピー先のディレクトリは、あらかじめ作っておく必要があります。$recursiveCallFlagがtrueの場合は、コピー先にサブディレクトリも作り、その中身もコピーします。シンボリックリンクは飛ばします。

どちらかのディレクトリがない場合や、コピーできなかったものがある場合はfalseを返します。

引数​

名前データ型デフォルト備考
$fromDirectorystringコピー元のディレクトリ
$toDirectorystringコピー先のディレクトリ(存在している必要があります)
$recursiveCallFlagbooleanfalsetrueにすると、サブディレクトリも再帰的にコピーします

例​

Controller
use Fegg\Tool\File;

$file = new File();

// Only the files directly under path/to/foo
$file->copyDirectory('path/to/foo', 'path/to/bar');

// Including subdirectories
$file->copyDirectory('path/to/foo', 'path/to/bar', true);