Convenience class for reading, writing and appending to files.
$Folder
public $handle
public resource
$info
public array
$lock
public boolean
$name
public string
$path
public mixed
Get the mime type of the file. Uses the finfo extension if its available, otherwise falls back to mime_content_type
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"
__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 clearStatCache( 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.
copy( string $dest , boolean $overwrite true )
Copy the File to $dest
$dest
$overwrite
optional true create( )
Creates the file.
delete( )
Deletes the file.
executable( )
Returns true if the File is executable.
exists( )
Returns true if the file exists.
ext( )
Returns the file extension.
folder( )
Returns the current folder.
Folder
group( )
Returns the file's group.
info( )
Returns the file info as an array with the following keys:
lastAccess( )
Returns last access time.
lastChange( )
Returns last modified time.
md5( integer|boolean $maxsize 5 )
Get md5 Checksum of file with previous check of Filesize
$maxsize
optional 5 mime( )
Get the mime type of the file. Uses the finfo extension if its available, otherwise falls back to mime_content_type
name( )
Returns the file name without extension.
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 open( string $mode 'r' , boolean $force false )
Opens the current file with a given $mode
$mode
optional 'r' $force
optional false owner( )
Returns the file's owner.
perms( )
Returns the "chmod" (permissions) of the file.
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 pwd( )
Returns the full path of the file.
read( 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 readable( )
Returns true if the file is readable.
replaceText( string|array $search , string|array $replace )
Searches for a given text and replaces the text if found.
$search
$replace
safe( string $name null , string $ext null )
Makes file name safe for saving
$name
optional null $ext
optional null size( )
Returns the file size
writable( )
Returns true if the file is writable.
write( string $data , string $mode 'w' , boolean $force false )
Write given data to this file.
$data
$mode
optional 'w' $force
optional false public Folder
Folder object of the file
null
© 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.
https://api.cakephp.org/2.9/class-File.html