Метод | Описание | |
---|---|---|
__toString ( ) : string | Returns filesystem object filepath. | |
copy ( string $dest ) : CFile | boolean | Copies the current filesystem object to specified destination. | |
create ( ) : CFile | boolean | Creates empty file if the current file doesn't exist. | |
createDir ( integer | string $permissions = 492, null | string $directory = null ) : boolean | CFile | Creates empty directory defined either through {@link set} or through the $directory parameter. | |
delete ( boolean $purge = True ) : boolean | Deletes the current filesystem object. | |
download ( null | string $fake_name = null, boolean $server_handled = False, null | string $content_type = null ) : boolean | null | Alias for {@link send}. | |
getBasename ( ) : string | Returns the current file basename (file name plus extension) from $_basename property set by {@link pathInfo} (e.g.: 'myfile.htm' for '/var/www/htdocs/files/myfile.htm'). | |
getContents ( boolean $recursive = False, string $filter = null ) : string | array | boolean | Returns the current filesystem object contents. | |
getDirname ( ) : string | Returns the current file directory name (without final slash) from $_dirname property set by {@link pathInfo} (e.g.: '/var/www/htdocs/files' for '/var/www/htdocs/files/myfile.htm') | |
getExists ( ) : boolean | Tests current filesystem object existence and returns boolean (see {@link exists}). | |
getExtension ( ) : string | Returns the current file extension from $_extension property set by {@link pathInfo} (e.g.: 'htm' for '/var/www/htdocs/files/myfile.htm'). | |
getFilename ( ) : string | Returns the current file name (without extension) from $_filename property set by {@link pathInfo} (e.g.: 'myfile' for '/var/www/htdocs/files/myfile.htm') | |
getGroup ( boolean $get_name = True ) : integer | string | boolean | Returns group of current filesystem object (UNIX systems). | |
getInstance ( string $filepath, string $class_name = __CLASS__ ) : object | Returns the instance of CFile for the specified file. | |
getIsDir ( ) : boolean | Returns filesystem object type for the current file (see {@link pathInfo}). | |
getIsEmpty ( ) : boolean | Returns filesystem object has-contents flag. | |
getIsFile ( ) : boolean | Returns filesystem object type for the current file (see {@link pathInfo}). | |
getIsUploaded ( ) : boolean | Tells whether file is uploaded through a web form. | |
getMimeType ( ) : string | boolean | Returns the MIME type of the current file. | |
getMimeTypeByExtension ( ) : string | Determines the MIME type based on the extension of the current file. | |
getOwner ( boolean $get_name = True ) : integer | string | boolean | Returns owner of current filesystem object (UNIX systems). | |
getPermissions ( ) : string | Returns permissions of current filesystem object (UNIX systems). | |
getReadable ( ) : boolean | Tests whether the current filesystem object is readable and returns boolean. | |
getRealPath ( string $dir_separator = DIRECTORY_SEPARATOR ) : string | Returns real filesystem object path figured by script (see {@link realPath}) on the basis of user supplied $_filepath. | |
getRelativePath ( ) : string | Returns relative filesystem object path figured by script on the basis of $_realpath | |
getSize ( string | boolean $format = '0.00' ) : string | integer | Returns size of current filesystem object. | |
getTimeCreated ( ) : integer | Returns the current file created time. Works on Windows System only! Returned Unix timestamp could be passed to php date() function. | |
getTimeModified ( ) : integer | Returns the current file last modified time. | |
getWriteable ( ) : boolean | Tests whether the current filesystem object is readable and returns boolean. | |
move ( string $dest ) : CFile | boolean | Alias for {@link rename}. | |
purge ( null | string $path = null ) : boolean | CFile | Purges (makes empty) the current filesystem object. | |
rename ( string $dest ) : CFile | boolean | Renames/moves the current filesystem object to specified destination. | |
send ( null | string $fake_name = null, boolean $server_handled = False, null | string $content_type = null ) : boolean | null | Sends the current file to browser as a download with real or faked file name. | |
set ( string $filepath, boolean $greedy = False ) : object | Basic CFile method. Sets CFile object to work with specified filesystem object. | |
setBasename ( null | string $basename = null ) : boolean | CFile | Sets basename for the current file. | |
setContents ( string $contents = null, boolean $autocreate = True, integer $flags ) : CFile | boolean | Writes contents (data) into the current file. | |
setExtension ( null | boolean | string $extension = False ) : boolean | CFile | Sets the current file extension. | |
setFilename ( null | string $filename = null ) : boolean | CFile | Sets the current file name. | |
setGroup ( string | integer $group, boolean $recursive = False ) : CFile | boolean | Sets the current filesystem object group, updates $_group property on success. | |
setOwner ( string | integer $owner, boolean $recursive = False ) : CFile | boolean | Sets the current filesystem object owner, updates $_owner property on success. | |
setPermissions ( string $permissions, boolean $recursive = False ) : CFile | boolean | Sets the current filesystem object permissions, updates $_permissions property on success. |
Метод | Описание | |
---|---|---|
addLog ( string $message, string $level = 'info' ) | Logs a message. | |
formatNumber ( number $number, string $format ) : string | Formats a given number into a given format and returns it. | |
getPathOfAlias ( string $alias ) : boolean | string | Returns filepath for a given alias. |
Метод | Описание | |
---|---|---|
close ( ) | Closes (if opened) the current file pointer. | |
dirContents ( null | string $directory = null, boolean $recursive = False, null | string $filter = null ) : array | Gets directory contents (descendant files and folders). | |
dirSize ( ) : integer | Calculates the current directory size recursively fetching sizes of all descendant files. | |
exists ( ) : boolean | Base filesystem object existence resolving method. | |
filterPassed ( string $str, array $filter ) : boolean | Applies an array of filter rules to the string representing filepath. | |
formatFileSize ( integer $bytes, string $format = '0.00' ) : string | Base filesystem object size format method. | |
open ( string $mode ) : boolean | CFile | Opens (if not already opened) the current file using certain mode. | |
pathInfo ( ) | Populates basic CFile properties (i.e. 'Dirname', 'Basename', etc.) using values resolved by pathinfo() php function. | |
realPath ( string $supplied_path, string $dir_separator = DIRECTORY_SEPARATOR ) : string | Base real filesystem object path resolving method. | |
resolveDestPath ( string $dest ) : string | Resolves destination path for the current filesystem object. |
public __toString ( ) : string | ||
Результат | string |
public createDir ( integer | string $permissions = 492, null | string $directory = null ) : boolean | CFile | ||
$permissions | integer | string | Access permissions for the directory |
$directory | null | string | Parameter used to create directory other than supplied by {@link set} method of the CFile |
Результат | boolean | CFile | Updated the current CFile object on success, 'False' on fail. |
public getBasename ( ) : string | ||
Результат | string | Current file basename |
public getContents ( boolean $recursive = False, string $filter = null ) : string | array | boolean | ||
$recursive | boolean | If True method would return all directory descendants. |
$filter | string | Filter to be applied to all directory descendants. Could be a string, or an array of strings (perl regexp are supported, if started with '~'). |
Результат | string | array | boolean | Data read for files, or directory contents names array. False on fail. |
public getDirname ( ) : string | ||
Результат | string | Current file directory name |
public getExtension ( ) : string | ||
Результат | string | Current file extension without the leading dot |
public getFilename ( ) : string | ||
Результат | string | Current file name |
public getIsEmpty ( ) : boolean | ||
Результат | boolean | 'True' if file is a directory, otherwise 'False' |
public getIsUploaded ( ) : boolean | ||
Результат | boolean | 'True' if file is uploaded, otherwise 'False' |
public getMimeType ( ) : string | boolean | ||
Результат | string | boolean | the MIME type on success, 'False' on fail. |
public getMimeTypeByExtension ( ) : string | ||
Результат | string | the MIME type. False is returned if the MIME type cannot be determined. |
public getPermissions ( ) : string | ||
Результат | string | Filesystem object permissions in octal format (i.e. '0755') |
public getReadable ( ) : boolean | ||
Результат | boolean | 'True' if filesystem object is readable, otherwise 'False' |
public getRealPath ( string $dir_separator = DIRECTORY_SEPARATOR ) : string | ||
$dir_separator | string | Directory separator char (depends upon OS) |
Результат | string | Real file path |
public getRelativePath ( ) : string | ||
Результат | string | Relative file path |
public getTimeCreated ( ) : integer | ||
Результат | integer | created at time Unix timestamp (e.g.: '1213760802') |
public getTimeModified ( ) : integer | ||
Результат | integer | Last modified time Unix timestamp (e.g.: '1213760802') |
public getWriteable ( ) : boolean | ||
Результат | boolean | 'True' if filesystem object is writeable, otherwise 'False' |
public send ( null | string $fake_name = null, boolean $server_handled = False, null | string $content_type = null ) : boolean | null | ||
$fake_name | null | string | New filename (e.g.: 'myfileFakedName.htm') |
$server_handled | boolean | Whether file contents delivery is handled by server internals (cf. when file contents is read and sent by php). E.g.: lighttpd and Apache with mod-sendfile can use X-Senfile header to speed up file delivery blazingly. Note: If you want to serve big or even huge files you are definetly advised to turn this option on and setup your server software appropriately, if not to say that it is your only alternative :). |
$content_type | null | string | Should be used to override content type on demand. |
Результат | boolean | null | Returns bool or outputs file contents with headers. |
public set ( string $filepath, boolean $greedy = False ) : object | ||
$filepath | string | Path to the file specified by user, if not set exception is raised |
$greedy | boolean | If True file properties (such as 'Size', 'Owner', 'Permission', etc.) would be autoloaded |
Результат | object | CFile instance for the specified filesystem object |
public setContents ( string $contents = null, boolean $autocreate = True, integer $flags ) : CFile | boolean | ||
$contents | string | Contents to be written |
$autocreate | boolean | If 'True' file will be created automatically |
$flags | integer | Flags for file_put_contents(). E.g.: FILE_APPEND to append data to file instead of overwriting. |
Результат | CFile | boolean | Current CFile object on success, 'False' on fail. |
public setPermissions ( string $permissions, boolean $recursive = False ) : CFile | boolean | ||
$permissions | string | New filesystem object permissions in numeric (octal, i.e. '0755') format |
$recursive | boolean | Apply permissions to directory contents flag. |
Результат | CFile | boolean | Current CFile object on success, 'False' on fail. |