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. 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
string $filename the name and path of the file
- $length
integer $length the number of bytes to read. Optional.
- $offset
integer $offset this will be the first byte which is read. Optional.
- $reverse
boolean $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
string $filename the name and path of the file
- $lines
integer $lines the number of lines to be read. Optional.
- $lineoffset
integer $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
string $filename the name and path of the file
- $content
string $content the data which should be written
- $append
boolean $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
string $filename the name and path to the file
- $content
string $content the data of the line
- $append
boolean $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
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
|
#
isDirectoryEmpty( string $dir )
Checks if a directory is empty
Checks if a directory is empty
Parameters
- $dir
string $dir Name of the directory
Returns
boolean true if the directory is empty
|
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
|
#
recursiveCopy( string $filename, string $destination )
Copies a directory and all of its subfolders.
Copies a directory and all of its subfolders.
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
|
#
setDefaultDirPerms( string $pathname )
Sets the default directory permissions on the given directory.
Sets the default directory permissions on the given directory.
Parameters
- $pathname
string $pathname the name of the directory
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 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
|
#
recursiveRmdir( string $dirname )
Deletes a directory and all of its contents.
Deletes a directory and all of its contents.
Parameters
- $dirname
string $dirname the name of the directory which should be deleted
Returns
boolean true on success or false on failure
Throws
|