Introduction
Providing some functions for managing files/directories
How to use
Import Fegg\Tool\File and create it with new.
Controller
<?php
namespace Site\Controller;
defined('FEGG_CORE_DIR') || exit;
use Fegg\Tool\File;
class Export extends Controller
{
public function index()
{
$file = new File();
$file->createDirectory(FEGG_SITE_DIR . '/data/export');
$file->writeFile(FEGG_SITE_DIR . '/data/export/list.csv', "id,title\n", 'w');
}
}
note
Most methods do nothing (no error, no return value) when the source file or directory does not exist. Check the result yourself, e.g. with file_exists(), when it matters.
Methods
File::copyAll
Copy all the files in a directory to another directory
File::copyDirectory
Copy the contents of a directory to another directory
File::copyFile
Copy a file
File::createDirectory
Create a directory
File::moveFile
Move (rename) a file
File::readFile
Read a file and return its contents
File::removeDirectory
Remove a directory with all its contents
File::removeExpiredFile
Remove the files older than the specified minutes
File::removeFile
Remove files
File::touchDirectory
Change the modification time of the files in a directory
File::writeFile
Write data to a file