File
class File (View source)
File helper.
Functions useful for working with files and directories.
Used as follows:
$file = Core::make('helper/file');
$path = 'http://www.concrete5.org/tools/get_latest_version_number';
$contents = $file->getContents($path);
echo $contents;
\@package Helpers
Methods
Returns the contents of a directory.
Removes the extension of a filename, uncamelcases it.
Recursively copies all items in the source directory or file to the target directory.
Returns an object with two permissions modes (octal): one for files: $res->file and another for directories: $res->dir.
Removes all files from within a specified directory.
Takes a path to a file and sends it to the browser, streaming it, and closing the HTTP connection afterwards. Basically a force download method.
Returns the full path to the temporary directory.
Adds content to a new line in a file. If a file is not there it will be created.
Just a consistency wrapper for file_get_contents Should use curl if it exists and fopen isn't allowed (thanks Remo).
Removes contents of the file.
Cleans up a filename and returns the cleaned up version.
Splits a filename into directory, base file name, extension.
Returns the extension for a file name.
Takes a path and replaces the files extension in that path with the specified extension.
Checks if two path are the same, considering directory separator and OS case sensitivity.
Try to set the executable bit of a file.
Details
getDirectoryContents($dir, $ignoreFiles = [], $recursive = false)
Returns the contents of a directory.
string
unfilename(string $filename)
Removes the extension of a filename, uncamelcases it.
copyAll(string $source, string $target, int $mode = null)
Recursively copies all items in the source directory or file to the target directory.
stdClass
getCreateFilePermissions(string $path = null)
Returns an object with two permissions modes (octal): one for files: $res->file and another for directories: $res->dir.
bool
removeAll(string $source, bool $inc = false)
Removes all files from within a specified directory.
forceDownload(stings $file)
Takes a path to a file and sends it to the browser, streaming it, and closing the HTTP connection afterwards. Basically a force download method.
string
getTemporaryDirectory()
Returns the full path to the temporary directory.
bool
append(string $filename, string $content)
Adds content to a new line in a file. If a file is not there it will be created.
string|bool
getContents($file, string $timeout = null)
Just a consistency wrapper for file_get_contents Should use curl if it exists and fopen isn't allowed (thanks Remo).
bool
clear($file)
Removes contents of the file.
string
sanitize(string $file)
Cleans up a filename and returns the cleaned up version.
array
splitFilename(string $filename)
Splits a filename into directory, base file name, extension.
If the file name starts with a dot and it's the only dot (eg: '.htaccess'), we don't consider the file to have an extension.
string
getExtension(string $filename)
Returns the extension for a file name.
string
replaceExtension(string $filename, string $extension)
Takes a path and replaces the files extension in that path with the specified extension.
bool
isSamePath(string $path1, string $path2)
Checks if two path are the same, considering directory separator and OS case sensitivity.
makeExecutable(string $file, string $who = 'all')
Try to set the executable bit of a file.