Useful Core Services for Working with Files
There are a number of useful core services available for working with files. Typically these don't involve Concrete CMS – they're general purpose helper methods.
Getting the Service
You can get access to the general file service this way:
$service = \Core::make('helper/file');
This returns an instance of the \Concrete\Core\File\Service\File object.
Here are some things you can do with this service.
Retrieve a list of files in a Directory
$files = $service->getDirectoryContents('/absolute/path/to/directory');
Recursively copy all items in a source directory to a target directory
Remove all files from a directory
Force the Download of a File
Get the Temporary Directory
$temporaryDirectory = $service->getTemporaryDirectory();
Get a file's extension
$extension = $service->getExtension($myFilename);
Checks if two path are the same, considering directory separator and OS case sensitivity.
$isSame = $service->isSamePath($path1, $path2);
There are additional methods available in this class. These are detailed in the API documentation: