Mark Story 5dee28d4f2 Use finfo better. 10 years ago
..
File.php 5dee28d4f2 Use finfo better. 10 years ago
Folder.php 8c05515025 replace DS with DIRECTORY_SEPARATOR in filesystem sub-package 10 years ago
README.md ccb1189c7b Fix extension in README 11 years ago
composer.json cb09cf69aa Prepare the filesystem package for a subsplit. 11 years ago

README.md

CakePHP Filesystem Library

The Folder and File utilities are convenience classes to help you read from and write/append to files; list files within a folder and other common directory related tasks.

Basic Usage

Create a folder instance and search for all the .ctp files within it:

use Cake\Filesystem\Folder;

$dir = new Folder('/path/to/folder');
$files = $dir->find('.*\.ctp');

Now you can loop through the files and read from or write/append to the contents or simply delete the file:

foreach ($files as $file) {
    $file = new File($dir->pwd() . DS . $file);
    $contents = $file->read();
    // $file->write('I am overwriting the contents of this file');
    // $file->append('I am adding to the bottom of this file.');
    // $file->delete(); // I am deleting this file
    $file->close(); // Be sure to close the file when you're done
}

Documentation

Please make sure you check the official documentation