Methods summary
public static
boolean
|
#
create( string $filename, string $content = '' )
Creates a new file
Parameters
- $filename
- the name and path of the new file
- $content
- optional content of the new file. Optional.
Returns
boolean true on success. Otherwise false.
|
public static
string
|
#
read( string $filename, integer $length = 0, integer $offset = 0, boolean $reverse = false )
Reads bytes from a file
Parameters
- $filename
- the name and path of the file
- $length
- the number of bytes to read. Optional.
- $offset
- this will be the first byte which is read. Optional.
- $reverse
if true, the function will start from the back of
the file. Optional.
Returns
string bool success it returns the bytes which have been read.
Otherwise false.
Throws
|
public static
string
|
#
readLine( string $filename, integer $lines = 0, integer $lineoffset = 0 )
Reads a file line by line
Reads a file line by line
Parameters
- $filename
- the name and path of the file
- $lines
- the number of lines to be read. Optional.
- $lineoffset
this will be the first line which is read.
Optional.
Returns
string array bool 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
- the name and path of the file
- $content
- the data which should be written
- $append
if true the data will be appended to the file.
Optional.
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
- the name and path to the file
- $content
- the data of the line
- $append
- if true the data will be appended to file. Optional.
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
- 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
- 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
- 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
- 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
- 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
- the name of the source file
- $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
- the name and path of the file
- $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
- the name and path of the file
- $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
- the name and path of the file
- $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
- 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
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
- 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
- the filename to validate
- $notifyAndExitOnFailure
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
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
Returns
boolean
|