Overview

Packages

  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Datatype
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • cApiPathresolveCacheHelper
  • cArray
  • cArticleCollector
  • cDirHandler
  • cFileHandler
  • cHTMLInputSelectElement
  • cIterator
  • cString
  • cZipArchive
  • UI_Config_Table
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo

Class cFileHandler

Class for file handling. Provides functions for dealing with files.

Package: Core\Util
Copyright: four for business AG <www.4fb.de>
License: http://www.contenido.org/license/LIZENZ.txt
Author: Mischa Holz
Located at classes/class.filehandler.php
Methods summary
public static boolean
# create( string $filename, string $content = '' )

Creates a new file

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

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

cInvalidArgumentException
if the file with the given filename does not exist
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

cInvalidArgumentException
if the file with the given filename does not exist
public static boolean
# write( string $filename, string $content, boolean $append = false )

Writes data to a file

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

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

cInvalidArgumentException
if the file with the given filename does not exist
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

cInvalidArgumentException
if the file with the given filename does not exist
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

cInvalidArgumentException
if the file with the given filename does not exist
public static boolean
# move( string $filename, string $destination )

Moves a file

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

cInvalidArgumentException
if the file with the given filename does not exist
public static boolean
# rename( string $filename, string $new_filename )

Renames a file

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

cInvalidArgumentException
if the file with the given filename does not exist
public static boolean
# copy( string $filename, string $destination )

Copies a file

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

cInvalidArgumentException
if the file with the given filename does not exist
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

cInvalidArgumentException
if the file with the given filename does not exist
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

cInvalidArgumentException
if the file with the given filename does not exist
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
# recursiveRmdir( mixed $dirname )

Deprecated

2013-11-11 - Use the class cDirHandler instead.

See

cDirHandler::recursiveRmdir()
public static
# recursiveCopy( mixed $filename, mixed $destination )

Deprecated

2013-11-11 - Use the class cDirHandler instead.

See

cDirHandler::recursiveCopy()
public static
# isDirectoryEmpty( mixed $dir )

Deprecated

2013-11-11 - Use the class cDirHandler instead.

See

cDirHandler::isDirectoryEmpty()
public static
# setDefaultDirPerms( mixed $dirname )

Deprecated

2013-11-11 - Use the class cDirHandler instead.

See

cDirHandler::setDefaultDirPerms()
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
# fileNameIsDot( string $fileName )

Check if given filename is either '.' or '..'.

Check if given filename is either '.' or '..'.

Parameters

$fileName
string
$fileName

Returns

boolean
CMS CONTENIDO 4.9.5 API documentation generated by ApiGen 2.8.0