File Class Info:
- Class Declaration:
class File
- File name:
- Cake/Utility/File.php
- Description:
Convenience class for reading, writing and appending to files.
- Package
- Cake.Utility
Properties:
-
Folder Folder
Folder object of the File
-
handle resource
Holds the file handler resource if the file is opened
http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::$handle
-
info array
File info
http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::$info
-
lock boolean
Enable locking for file reading and writing
http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::$lock
-
name string
Filename
http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::$name
-
path mixed null
Path property
Current file's absolute path
http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::$path
Method Summary:
- append( $data, $force = false )
- close( )
- __construct( $path, $create = false, $mode = 493 )
- copy( $dest, $overwrite = true )
- create( )
- delete( )
- __destruct( )
- executable( )
- exists( )
- ext( )
- folder( )
- group( )
- info( )
- lastAccess( )
- lastChange( )
- md5( $maxsize = 5 )
- mime( )
- name( )
- offset( $offset = false, $seek = 0 )
- open( $mode = 'r', $force = false )
- owner( )
- perms( )
- prepare( $data, $forceWindows = false )
- pwd( )
- read( $bytes = false, $mode = 'rb', $force = false )
- readable( )
- safe( $name = NULL, $ext = NULL )
- size( )
- writable( )
- write( $data, $mode = 'w', $force = false )
append
topAppend given data string to this File.
- Parameters:
-
-
string $data required
Data to write
-
string $force optional false
force the file to open
-
- Method defined in:
- Cake/Utility/File.php on line 256
- Return
boolean Success
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::append
close
topCloses the current file if it is opened.
- Method defined in:
- Cake/Utility/File.php on line 266
- Return
boolean True if closing was successful or file was already closed, otherwise false
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::close
__construct
topConstructor
- Parameters:
-
-
string $path required
Path to file
-
boolean $create optional false
Create file if it does not exist (if true)
-
integer $mode optional 493
Mode to apply to the folder holding the file
-
- Method defined in:
- Cake/Utility/File.php on line 87
copy
topCopy the File to $dest
- Parameters:
-
-
string $dest required
destination for the copy
-
boolean $overwrite optional true
Overwrite $dest if exists
-
- Method defined in:
- Cake/Utility/File.php on line 541
- Return
boolean Success
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::copy
create
topCreates the File.
- Method defined in:
- Cake/Utility/File.php on line 110
- Return
boolean Success
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::create
delete
topDeletes the File.
- Method defined in:
- Cake/Utility/File.php on line 279
- Return
boolean Success
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::delete
__destruct
topexecutable
topReturns true if the File is executable.
- Method defined in:
- Cake/Utility/File.php on line 457
- Return
boolean true if its executable, false otherwise
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::executable
exists
topReturns true if the File exists.
- Method defined in:
- Cake/Utility/File.php on line 411
- Return
boolean true if it exists, false otherwise
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::exists
ext
topReturns the File extension.
- Method defined in:
- Cake/Utility/File.php on line 326
- Return
string The File extension
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::ext
folder
topReturns the current folder.
- Method defined in:
- Cake/Utility/File.php on line 529
- Return
Folder Current folder
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::Folder
group
topReturns the File's group.
- Method defined in:
- Cake/Utility/File.php on line 490
- Return
integer the Filegroup
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::group
info
topReturns the File info as an array with the following keys:
- dirname
- basename
- extension
- filename
- filesize
- mime
- Method defined in:
- Cake/Utility/File.php on line 304
- Return
array File information.
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::info
lastAccess
topReturns last access time.
- Method defined in:
- Cake/Utility/File.php on line 503
- Return
integer timestamp Timestamp of last access time
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::lastAccess
lastChange
topReturns last modified time.
- Method defined in:
- Cake/Utility/File.php on line 516
- Return
integer timestamp Timestamp of last modification
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::lastChange
md5
topGet md5 Checksum of file with previous check of Filesize
- Parameters:
-
-
mixed $maxsize optional 5
in MB or true to force
-
- Method defined in:
- Cake/Utility/File.php on line 379
- Return
string md5 Checksum {@link http://php.net/md5_file See md5_file()}
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::md5
mime
topGet the mime type of the file. Uses the finfo extension if its available, otherwise falls back to mime_content_type
- Method defined in:
- Cake/Utility/File.php on line 554
- Return
false|string The mimetype of the file, or false if reading fails.
name
topReturns the File name without extension.
- Method defined in:
- Cake/Utility/File.php on line 342
- Return
string The File name without extension.
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::name
offset
topSets or gets the offset for the currently opened file.
- Parameters:
-
-
mixed $offset optional false
The $offset in bytes to seek. If set to false then the current offset is returned.
-
integer $seek optional 0
PHP Constant SEEK_SET | SEEK_CUR | SEEK_END determining what the $offset is relative to
-
- Method defined in:
- Cake/Utility/File.php on line 191
- Return
mixed True on success, false on failure (set mode), false on failure or integer offset on success (get mode)
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::offset
open
topOpens the current file with a given $mode
- Parameters:
-
-
string $mode optional 'r'
A valid 'fopen' mode string (r|w|a ...)
-
boolean $force optional false
If true then the file will be re-opened even if its already opened, otherwise it won't
-
- Method defined in:
- Cake/Utility/File.php on line 128
- Return
boolean True on success, false on failure
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::open
owner
topReturns the File's owner.
- Method defined in:
- Cake/Utility/File.php on line 477
- Return
integer the Fileowner
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::owner
perms
topReturns the "chmod" (permissions) of the File.
- Method defined in:
- Cake/Utility/File.php on line 421
- Return
string Permissions for the file
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::perms
prepare
topPrepares a 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"
- Parameters:
-
-
string $data required
Data to prepare for writing.
-
boolean $forceWindows optional false
Data to prepare for writing.
-
- Method defined in:
- Cake/Utility/File.php on line 212
- Return
string The with converted line endings.
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::prepare
pwd
topReturns the full path of the File.
- Method defined in:
- Cake/Utility/File.php on line 398
- Return
string Full path to file
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::pwd
read
topReturn the contents of this File as a string.
- Parameters:
-
-
string $bytes optional false
where to start
-
string $mode optional 'rb'
A
freadcompatible mode. -
boolean $force optional false
If true then the file will be re-opened even if its already opened, otherwise it won't
-
- Method defined in:
- Cake/Utility/File.php on line 155
- Return
mixed string on success, false on failure
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::read
readable
topReturns true if the File is readable.
- Method defined in:
- Cake/Utility/File.php on line 467
- Return
boolean true if file is readable, false otherwise
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::readable
safe
topmakes filename safe for saving
- Parameters:
-
-
string $name optional NULL
The name of the file to make safe if different from $this->name
-
string $ext optional NULL
The name of the extension to make safe if different from $this->ext
-
- Method defined in:
- Cake/Utility/File.php on line 362
- Return
string $ext the extension of the file
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::safe
size
topReturns the Filesize
- Method defined in:
- Cake/Utility/File.php on line 434
- Return
integer size of the file in bytes, or false in case of an error
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::size
writable
topReturns true if the File is writable.
- Method defined in:
- Cake/Utility/File.php on line 447
- Return
boolean true if its writable, false otherwise
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::writable
write
topWrite given data to this File.
- Parameters:
-
-
string $data required
Data to write to this File.
-
string $mode optional 'w'
Mode of writing. {@link http://php.net/fwrite See fwrite()}.
-
string $force optional false
force the file to open
-
- Method defined in:
- Cake/Utility/File.php on line 229
- Return
boolean Success
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::write
