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 , string $force false )
Append given data string to this file.
$data $force optional false booleanclearStatCache( boolean $all false )
Clear PHP's internal stat cache
For 5.3 onwards it's possible to clear cache for just a single file. Passing true will clear all the stat cache.
$all optional false close( )
Closes the current file if it is opened.
booleancopy( string $dest , boolean $overwrite true )
Copy the File to $dest
$dest $overwrite optional true booleancreate( )
Creates the file.
booleandelete( )
Deletes the file.
booleanexecutable( )
Returns true if the File is executable.
booleanexists( )
Returns true if the file exists.
booleanext( )
Returns the file extension.
stringfolder( )
Returns the current folder.
Foldergroup( )
Returns the file's group.
integer|falseinfo( )
Returns the file info as an array with the following keys:
arraylastAccess( )
Returns last access time.
integer|falselastChange( )
Returns last modified time.
integer|falsemd5( integer|boolean $maxsize 5 )
Get md5 Checksum of file with previous check of Filesize
$maxsize optional 5 string|falsemime( )
Get the mime type of the file. Uses the finfo extension if its available, otherwise falls back to mime_content_type
false|stringname( )
Returns the file name without extension.
stringoffset( 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 mixedopen( string $mode 'r' , boolean $force false )
Opens the current file with a given $mode
$mode optional 'r' $force optional false booleanowner( )
Returns the file's owner.
integer|falseperms( )
Returns the "chmod" (permissions) of the file.
string|falseprepare( 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 stringpwd( )
Returns the full path of the file.
stringread( string $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 mixedreadable( )
Returns true if the file is readable.
booleanreplaceText( string|array $search , string|array $replace )
Searches for a given text and replaces the text if found.
$search $replace booleansafe( string $name null , string $ext null )
Makes file name safe for saving
$name optional null $ext optional null stringsize( )
Returns the file size
integer|falsewritable( )
Returns true if the file is writable.
booleanwrite( string $data , string $mode 'w' , string $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/2.7/class-File.html