Convenience class for reading, writing and appending to files.
__construct( string $path , boolean $create false , integer $mode 0755 )
Constructor
$path
$create
optional false $mode
optional 0755 append( string $data , boolean $force false )
Append given data string to this file.
$data
$force
optional false boolean
clearStatCache( boolean $all false )
Clear PHP's internal stat cache
$all
optional false close( )
Closes the current file if it is opened.
boolean
copy( string $dest , boolean $overwrite true )
Copy the File to $dest
$dest
$overwrite
optional true boolean
executable( )
Returns true if the File is executable.
boolean
exists( )
Returns true if the file exists.
boolean
ext( )
Returns the file extension.
string|false
folder( )
Returns the current folder.
Cake\Filesystem\Folder
group( )
Returns the file's group.
integer|false
info( )
Returns the file info as an array with the following keys:
array
lastAccess( )
Returns last access time.
integer|false
lastChange( )
Returns last modified time.
integer|false
md5( integer|boolean $maxsize 5 )
Get md5 Checksum of file with previous check of Filesize
$maxsize
optional 5 string|false
mime( )
Get the mime type of the file. Uses the finfo extension if its available, otherwise falls back to mime_content_type
false|string
name( )
Returns the file name without extension.
string|false
offset( integer|boolean $offset false , integer $seek SEEK_SET )
Sets or gets the offset for the currently opened file.
$offset
optional false $seek
optional SEEK_SET integer|boolean
open( string $mode 'r' , boolean $force false )
Opens the current file with a given $mode
$mode
optional 'r' $force
optional false boolean
owner( )
Returns the file's owner.
integer|false
perms( )
Returns the "chmod" (permissions) of the file.
string|false
prepare( string $data , boolean $forceWindows false )
Prepares an ASCII string for writing. Converts line endings to the correct terminator for the current platform. If Windows, "\r\n" will be used, all other platforms will use "\n"
$data
$forceWindows
optional false string
read( string|boolean $bytes false , string $mode 'rb' , boolean $force false )
Return the contents of this file as a string.
$bytes
optional false $mode
optional 'rb' fread
compatible mode.$force
optional false string|false
readable( )
Returns true if the file is readable.
boolean
replaceText( string|array $search , string|array $replace )
Searches for a given text and replaces the text if found.
$search
$replace
boolean
safe( string|null $name null , string|null $ext null )
Makes file name safe for saving
$name
optional null $ext
optional null string
size( )
Returns the file size
integer|false
writable( )
Returns true if the file is writable.
boolean
write( string $data , string $mode 'w' , boolean $force false )
Write given data to this file.
$data
$mode
optional 'w' $force
optional false boolean
© 2005–2016 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
http://api.cakephp.org/3.1/class-Cake.Filesystem.File.html