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

File::removeExpiredFile

指定した分数より古いファイルを削除します

説明​

public bool File::removeExpiredFile( string $path, int $min )

$pathの直下にあるファイルのうち、更新日時が$min分以上前のものを削除します。サブディレクトリには触れません。

期限切れのファイルをすべて削除できたら(該当するファイルがなかった場合も)trueを返します。$pathがディレクトリでない場合や、削除できなかったファイルがある場合はfalseを返します。

引数​

名前データ型デフォルト備考
$pathstring対象のディレクトリ
$minintファイルを削除するまでの経過時間(分)

例​

Controller
use Fegg\Tool\File;

$file = new File();

// Delete temporary files older than one day
$file->removeExpiredFile('path/to/tmp', 60 * 24);