Methods summary
public static
boolean
|
#
create( string $filename, string $content = '' )
Creates a new file
Parameters
- $filename
string $filename the name and path of the new file
- $content
string $content [optional] content of the new file
Returns
boolean true on success. Otherwise false.
|
public static
string|boolean
|
#
read( string $filename, integer $length = 0, integer $offset = 0, boolean $reverse = false )
Reads bytes from a file
Parameters
- $filename
string $filename the name and path of the file
- $length
integer $length [optional] the number of bytes to read.
- $offset
integer $offset [optional] this will be the first byte which is read.
- $reverse
boolean $reverse [optional] if true, the function will start from the back of the file.
Returns
string|boolean On success it returns the bytes which have been read. Otherwise false.
Throws
|
public static
string|array|boolean
|
#
readLine( string $filename, integer $lines = 0, integer $lineoffset = 0 )
Reads a file line by line
Reads a file line by line
Parameters
- $filename
string $filename the name and path of the file
- $lines
integer $lines [optional] the number of lines to be read.
- $lineoffset
integer $lineoffset [optional] this will be the first line which is read.
Returns
string|array|boolean If one line was read the function will return it. If more than one line was read
the function will return an array containing the lines. Otherwise false is
returned
Throws
|
public static
boolean
|
#
write( string $filename, string $content, boolean $append = false )
Writes data to a file
Parameters
- $filename
string $filename the name and path of the file
- $content
string $content the data which should be written
- $append
boolean $append [optional] if true the data will be appended to the file.
Returns
boolean true on success, false otherwise
|
public static
boolean
|
#
writeLine( string $filename, string $content, boolean $append = false )
Writes a line to a file (this is similar to cFileHandler::write($filename,
$data."\n", $apppend)
Writes a line to a file (this is similar to cFileHandler::write($filename,
$data."\n", $apppend)
Parameters
- $filename
string $filename the name and path to the file
- $content
string $content the data of the line
- $append
boolean $append [optional] if true the data will be appended to file.
Returns
boolean true on success, false otherwise
See
cFileHandler::write($filename, $content, $append)
|
public static
boolean
|
#
exists( string $filename )
Checks if a file exists
Parameters
- $filename
string $filename the name and path of the file
Returns
boolean true if the file exists
|
public static
boolean
|
#
writeable( string $filename )
Checks if the file is writable for the PHP user
Checks if the file is writable for the PHP user
Parameters
- $filename
string $filename the name and path of the file
Returns
boolean true if the file can be written
|
public static
boolean
|
#
readable( string $filename )
Checks if a file is readable for the PHP user
Checks if a file is readable for the PHP user
Parameters
- $filename
string $filename the name and path of the file
Returns
boolean true if the file is readable
Throws
|
public static
boolean
|
#
remove( string $filename )
Removes a file from the filesystem
Removes a file from the filesystem
Parameters
- $filename
string $filename the name and path of the file
Returns
boolean true on success
Throws
|
public static
boolean
|
#
truncate( string $filename )
Truncates a file so that it is empty
Truncates a file so that it is empty
Parameters
- $filename
string $filename the name and path of the file
Returns
boolean true on success
Throws
|
public static
boolean
|
#
move( string $filename, string $destination )
Moves a file
Parameters
- $filename
string $filename the name of the source file
- $destination
string $destination the destination. Note that the file can also be renamed in the
process of moving it
Returns
boolean true on success
Throws
|
public static
boolean
|
#
rename( string $filename, string $new_filename )
Renames a file
Parameters
- $filename
string $filename the name and path of the file
- $new_filename
string $new_filename the new name of the file
Returns
boolean true on success
Throws
|
public static
boolean
|
#
copy( string $filename, string $destination )
Copies a file
Parameters
- $filename
string $filename the name and path of the file
- $destination
string $destination the destination. Note that existing files get overwritten
Returns
boolean true on success
Throws
|
public static
boolean
|
#
chmod( string $filename, integer $mode )
Changes the file permissions
Changes the file permissions
Parameters
- $filename
string $filename the name and path of the file
- $mode
integer $mode the new access mode : php chmod needs octal value
Returns
boolean true on success
Throws
|
public static
array
|
#
info( string $filename )
Returns an array containing information about the file. Currently following
elements are in it: 'size' - the file size (in byte) 'atime' - the time the file
was last accessed (unix timestamp) 'ctime' - time the file was created (unix
timestamp) 'mtime' - time the file was last modified (unix timestamp) 'perms' -
permissions of the file represented in 4 octal digits 'extension' - the file
extension or '' if there's no extension 'mime' - the mime type of the file
Returns an array containing information about the file. Currently following
elements are in it: 'size' - the file size (in byte) 'atime' - the time the file
was last accessed (unix timestamp) 'ctime' - time the file was created (unix
timestamp) 'mtime' - time the file was last modified (unix timestamp) 'perms' -
permissions of the file represented in 4 octal digits 'extension' - the file
extension or '' if there's no extension 'mime' - the mime type of the file
Parameters
- $filename
string $filename the name and path to the file
Returns
array Returns an array containing information about the file
Throws
|
public static
string
|
#
getExtension( string $basename )
Returns the extension of passed filename
Returns the extension of passed filename
Parameters
- $basename
string $basename
Returns
string
|
public static
boolean
|
#
setDefaultFilePerms( string $filename )
Sets the default file permissions on the given file.
Sets the default file permissions on the given file.
Parameters
- $filename
string $filename the name of the file
Returns
boolean true on success or false on failure
|
public static
boolean
|
#
validateFilename( string $filename, boolean $notifyAndExitOnFailure = true )
Validates the given filename.
Validates the given filename.
Parameters
- $filename
string $filename the filename to validate
- $notifyAndExitOnFailure
boolean $notifyAndExitOnFailure [optional] if set, function will show a notification and
will exit the script
Returns
boolean true if the given filename is valid, false otherwise
|
public static
boolean
|
#
fileNameIsDot( string $fileName )
Check if given filename is either '.' or '..'.
Check if given filename is either '.' or '..'.
Parameters
- $fileName
string $fileName
Returns
boolean
|
public static
boolean
|
#
fileNameBeginsWithDot( string $fileName )
Check if file name begins with a period.
Check if file name begins with a period.
Parameters
- $fileName
string $fileName
Returns
boolean
|