eZ Publish  [4.2]
eZFileHandler Class Reference

Interface for file handlers. More...

+ Inheritance diagram for eZFileHandler:

List of all members.

Public Member Functions

 close ()
 doClose ()
 doEOF ()
 doFlush ()
 doOpen ($filename, $mode)
 doPasstrough ($closeFile=true)
 doRead ($length=false)
 doRewind ()
 doSeek ($offset, $whence)
 doTell ()
 doWrite ($data, $length=false)
 duplicate ()
 eof ()
 error ()
 errorNumber ()
 errorString ()
 exists ($filename=false)
 eZFileHandler ($handlerIdentifier=false, $handlerName=false)
 filename ()
 flush ()
 identifier ()
 isBinaryMode ()
 isDirectory ($filename=false)
 isExecutable ($filename=false)
 isFile ($filename=false)
 isLink ($filename=false)
 isOpen ()
 isReadable ($filename=false)
 isWriteable ($filename=false)
 mode ()
 name ()
 open ($filename, $mode, $binaryFile=true)
 passtrough ($closeFile=true)
 read ($length=false)
 rename ($destinationFilename, $sourceFilename=false)
 rewind ()
 seek ($offset, $whence=SEEK_SET)
 statistics ($filename=false)
 tell ()
 write ($data, $length=false)

Static Public Member Functions

static copy ($sourceFilename, $destinationFilename)
static doExists ($filename)
static doIsDirectory ($filename)
static doIsExecutable ($filename)
static doIsFile ($filename)
static doIsLink ($filename)
static doIsReadable ($filename)
static doIsWriteable ($filename)
static doRename ($destinationFilename, $sourceFilename)
static doStatistics ($filename)
static doUnlink ($filename)
static instance ($identifier, $filename=false, $mode=false, $binaryFile=true)
 Returns a shared instance of the eZFileHandler class.
static isAvailable ()
static link ($sourceFilename, $destinationFilename)
static linkCopy ($sourceFilename, $destinationFilename, $symbolicLink=true)
static move ($sourceFilename, $destinationFilename)
static symlink ($sourceFilename, $destinationFilename)
static unlink ($filename=false)

Public Attributes

 $FileName
 $IsBinary
 $IsOpen
 $Mode
 $Name

Detailed Description

Interface for file handlers.

Generic interface for all file handlers.

Using this class i divided into five areas, they are:

File handling using open(), close(), read(), write() and flush().

File position handling using seek(), tell(), rewind() and eof().

Quick output of the file using passtrough().

Error handling with error(), errorString() and errorNumber().

Creating specific handlers

The file handlers must inherit from this class and reimplement some virtual functions.

For dealing with files the following functions must be reimplemented. doOpen(), doClose(), doRead(), doWrite() and doFlush().

For dealing with file positions the following functions must be reimplemented. doSeek(), doTell(), doRewind() and doEOF().

For dealing with quick output the passtrough() function must be reimplemented, if not reimplemented the default implemententation will simply read n bytes using read() and output it with print.

Also the errorString() and errorNumber() functions must be reimplemented to provide proper error handler. The error() function is not required to be implemented since it has a default implementation, for speed it might be wise to implement the function.

This class will handle most of the generic logic, like checking that the filename is correct and if the open succeded, and give error messages based on this. The actual implementations will only have to execute the specific code and return a result.

Definition at line 78 of file ezfilehandler.php.


Member Function Documentation

eZFileHandler::close ( )

Tries to close an open file and returns true if succesful, false otherwise.

Definition at line 578 of file ezfilehandler.php.

Referenced by rename(), and unlink().

eZFileHandler::doClose ( ) [pure virtual]

Does the actual file closing.

See also:
close

Implemented in eZGZIPZLIBCompressionHandler, eZGZIPShellCompressionHandler, eZForwardCompressionHandler, and eZBZIP2Handler.

Definition at line 812 of file ezfilehandler.php.

Referenced by close().

eZFileHandler::doEOF ( ) [pure virtual]

Does the actual file eof detection.

See also:
eof

Implemented in eZGZIPZLIBCompressionHandler, eZGZIPShellCompressionHandler, and eZForwardCompressionHandler.

Definition at line 944 of file ezfilehandler.php.

Referenced by eof().

static eZFileHandler::doExists ( filename) [static, pure virtual]

Does the actual file exists checking.

See also:
exists

Definition at line 834 of file ezfilehandler.php.

Referenced by exists().

eZFileHandler::doFlush ( ) [pure virtual]

Does the actual file flushing.

See also:
flush

Implemented in eZGZIPZLIBCompressionHandler, eZGZIPShellCompressionHandler, eZForwardCompressionHandler, and eZBZIP2Handler.

Definition at line 992 of file ezfilehandler.php.

Referenced by flush().

static eZFileHandler::doIsDirectory ( filename) [static, pure virtual]

Does the actual directory checking.

See also:
isDirectory

Definition at line 844 of file ezfilehandler.php.

Referenced by isDirectory().

static eZFileHandler::doIsExecutable ( filename) [static, pure virtual]

Does the actual executable checking.

See also:
isExecutable

Definition at line 854 of file ezfilehandler.php.

Referenced by isExecutable().

static eZFileHandler::doIsFile ( filename) [static, pure virtual]

Does the actual file checking.

See also:
isFile

Definition at line 864 of file ezfilehandler.php.

Referenced by isFile().

static eZFileHandler::doIsLink ( filename) [static, pure virtual]

Does the actual link checking.

See also:
isLink

Definition at line 874 of file ezfilehandler.php.

Referenced by isLink().

static eZFileHandler::doIsReadable ( filename) [static, pure virtual]

Does the actual readable checking.

See also:
isReadable

Definition at line 884 of file ezfilehandler.php.

Referenced by isReadable().

static eZFileHandler::doIsWriteable ( filename) [static, pure virtual]

Does the actual writeable checking.

See also:
isWriteable

Definition at line 894 of file ezfilehandler.php.

Referenced by isWriteable().

eZFileHandler::doOpen ( filename,
mode 
) [pure virtual]

Does the actual file opening.

See also:
open

Implemented in eZGZIPShellCompressionHandler, eZGZIPZLIBCompressionHandler, eZForwardCompressionHandler, and eZBZIP2Handler.

Definition at line 801 of file ezfilehandler.php.

Referenced by open().

eZFileHandler::doPasstrough ( closeFile = true) [pure virtual]

Does the actual file passtrough.

See also:
eof

Implemented in eZGZIPZLIBCompressionHandler, eZGZIPShellCompressionHandler, and eZForwardCompressionHandler.

Definition at line 954 of file ezfilehandler.php.

Referenced by passtrough().

eZFileHandler::doRead ( length = false) [pure virtual]

Does the actual file reading.

See also:
read

Implemented in eZGZIPZLIBCompressionHandler, eZGZIPShellCompressionHandler, eZForwardCompressionHandler, and eZBZIP2Handler.

Definition at line 969 of file ezfilehandler.php.

Referenced by read().

static eZFileHandler::doRename ( destinationFilename,
sourceFilename 
) [static, pure virtual]

Does the actual file renaming.

See also:
rename

Definition at line 1002 of file ezfilehandler.php.

Referenced by rename().

eZFileHandler::doRewind ( )

Does the actual file rewind.

See also:
rewind
Note:
Default implementation calls seek with offset set to 0 from the file start.

Reimplemented in eZGZIPZLIBCompressionHandler, eZGZIPShellCompressionHandler, and eZForwardCompressionHandler.

Definition at line 924 of file ezfilehandler.php.

Referenced by rewind().

eZFileHandler::doSeek ( offset,
whence 
) [pure virtual]

Does the actual file seek.

See also:
seek

Implemented in eZGZIPZLIBCompressionHandler, eZGZIPShellCompressionHandler, and eZForwardCompressionHandler.

Definition at line 914 of file ezfilehandler.php.

Referenced by doRewind(), and seek().

static eZFileHandler::doStatistics ( filename) [static, pure virtual]

Does the actual writeable checking.

See also:
isWriteable

Definition at line 904 of file ezfilehandler.php.

Referenced by statistics().

eZFileHandler::doTell ( ) [pure virtual]

Does the actual file telling.

See also:
tell

Implemented in eZGZIPZLIBCompressionHandler, eZGZIPShellCompressionHandler, and eZForwardCompressionHandler.

Definition at line 934 of file ezfilehandler.php.

Referenced by tell().

static eZFileHandler::doUnlink ( filename) [static, pure virtual]

Does the actual file unlinking.

See also:
unlink

Definition at line 824 of file ezfilehandler.php.

Referenced by unlink().

eZFileHandler::doWrite ( data,
length = false 
) [pure virtual]

Does the actual file writing.

See also:
write

Implemented in eZGZIPZLIBCompressionHandler, eZGZIPShellCompressionHandler, eZForwardCompressionHandler, and eZBZIP2Handler.

Definition at line 979 of file ezfilehandler.php.

Referenced by write().

eZFileHandler::duplicate ( )

Creates a copy of the current handler and returns a reference to the copy.

Note:
The default does a simple copy of $this, this method must be reimplemented for specific handlers.

Reimplemented in eZForwardCompressionHandler.

Definition at line 1041 of file ezfilehandler.php.

eZFileHandler::eof ( )
Returns:
true if the file pointer is at the end of the file or an error occured, otherwise false.

Definition at line 769 of file ezfilehandler.php.

eZFileHandler::error ( )

Returns error data as an associative array, the array contains:

Reimplemented in eZForwardCompressionHandler, and eZBZIP2Handler.

Definition at line 1013 of file ezfilehandler.php.

eZFileHandler::errorNumber ( ) [pure virtual]
Returns:
the error number from the last error that occured.

Implemented in eZGZIPZLIBCompressionHandler, eZGZIPShellCompressionHandler, eZForwardCompressionHandler, and eZBZIP2Handler.

Definition at line 1032 of file ezfilehandler.php.

Referenced by error().

eZFileHandler::errorString ( ) [pure virtual]
Returns:
the error string from the last error that occured.

Implemented in eZGZIPZLIBCompressionHandler, eZGZIPShellCompressionHandler, eZForwardCompressionHandler, and eZBZIP2Handler.

Definition at line 1023 of file ezfilehandler.php.

Referenced by error().

eZFileHandler::exists ( filename = false)
Returns:
true if the filename $filename exists. If $filename is not specified the filename is taken from the one used in open().

Definition at line 448 of file ezfilehandler.php.

eZFileHandler::eZFileHandler ( handlerIdentifier = false,
handlerName = false 
)

Initializes the handler. Optionally the parameters $filename and $mode may be provided to automatically open the file.

Definition at line 84 of file ezfilehandler.php.

Referenced by eZCompressionHandler\eZCompressionHandler(), and instance().

eZFileHandler::filename ( )
Returns:
the filename currently in use.

Definition at line 119 of file ezfilehandler.php.

Referenced by eZGZIPZLIBCompressionHandler\doPasstrough(), and rename().

eZFileHandler::flush ( )

Force a write of all buffered data.

Returns:
true if succesful or false if something failed.

Definition at line 705 of file ezfilehandler.php.

eZFileHandler::identifier ( )
Returns:
the identifier of the current handler.
See also:
name

Definition at line 145 of file ezfilehandler.php.

Referenced by eZForwardCompressionHandler\duplicate().

static eZFileHandler::instance ( identifier,
filename = false,
mode = false,
binaryFile = true 
) [static]

Returns a shared instance of the eZFileHandler class.

Returns the handler for the identifier $identifier. The parameters $filename, $mode and $binaryFile is passed to the handler.

Returns:
false if the handler could not be created. $identifier if set is used to specify specific file handlers as defined in file.ini [FileSettings]Handlers. If $filename and later params are set, then file is opened straigt away.
Parameters:
$identifierstring|false Global eZFileHandler used if false
$filenamestring|false
$modestring|false set to 'r' if false
$binaryFilebool binary or text mode, default true.
Returns:
eZFileHandler|false

Definition at line 1064 of file ezfilehandler.php.

Referenced by eZCache\clearItem(), eZFSFileHandler\delete(), and eZFSFileHandler\fileDelete().

static eZFileHandler::isAvailable ( ) [static]
Returns:
true if this handler can be used.
Note:
The default implementation is to return true for all handlers.

Reimplemented in eZGZIPShellCompressionHandler, and eZGZIPZLIBCompressionHandler.

Definition at line 154 of file ezfilehandler.php.

eZFileHandler::isBinaryMode ( )
Returns:
true if the file was opened in binary mode.

Definition at line 111 of file ezfilehandler.php.

Referenced by eZGZIPZLIBCompressionHandler\doPasstrough().

eZFileHandler::isDirectory ( filename = false)
Returns:
true if $filename is a directory.

Definition at line 458 of file ezfilehandler.php.

eZFileHandler::isExecutable ( filename = false)
Returns:
true if $filename is executable.

Definition at line 468 of file ezfilehandler.php.

eZFileHandler::isFile ( filename = false)
Returns:
true if $filename is a file.

Definition at line 478 of file ezfilehandler.php.

eZFileHandler::isLink ( filename = false)
Returns:
true if $filename is a link.

Definition at line 488 of file ezfilehandler.php.

eZFileHandler::isOpen ( )
Returns:
true if a file is opened, false otherwise.

Definition at line 103 of file ezfilehandler.php.

Referenced by close(), eof(), flush(), open(), passtrough(), read(), rename(), rewind(), seek(), tell(), unlink(), and write().

eZFileHandler::isReadable ( filename = false)
Returns:
true if $filename is readable.

Definition at line 498 of file ezfilehandler.php.

eZFileHandler::isWriteable ( filename = false)
Returns:
true if $filename is writeable.

Definition at line 508 of file ezfilehandler.php.

static eZFileHandler::link ( sourceFilename,
destinationFilename 
) [static]

Creates a symbolic link to the file $sourceFilename on the destination $destinationFilename. This means that if someone tries to open $destinationFilename they will infact open $sourceFilename. If $destinationFilename is a directory then the filename is taken from $sourceFilename and appended to the destination. It will first try to rename the file and if that does not work copy the file and unlink.

Returns:
true if sucessful or false if the copy failed.

Definition at line 265 of file ezfilehandler.php.

Referenced by linkCopy().

static eZFileHandler::linkCopy ( sourceFilename,
destinationFilename,
symbolicLink = true 
) [static]

Links the file $sourceFilename to $destinationFilename. If $destinationFilename is a directory then the filename is taken from $sourceFilename and appended to the destination. It will use symbolic links for the operating system that support it and file copy for all others.

Parameters:
$symbolicLinkif true then the files will be made as symbolic links, otherwise as hard links.
Returns:
true if sucessful or false if the copy failed.

Definition at line 166 of file ezfilehandler.php.

Referenced by eZImageManager\convert(), and eZFSFileHandler\fileLinkCopy().

eZFileHandler::mode ( )
Returns:
the mode which was used to open the currently used file.

Definition at line 127 of file ezfilehandler.php.

Referenced by eZGZIPZLIBCompressionHandler\doPasstrough(), and rename().

static eZFileHandler::move ( sourceFilename,
destinationFilename 
) [static]

Moves the file $sourceFilename to $destinationFilename. If $destinationFilename is a directory then the filename is taken from $sourceFilename and appended to the destination. It will first try to rename the file and if that does not work copy the file and unlink.

Returns:
true if sucessful or false if the copy failed.

Definition at line 314 of file ezfilehandler.php.

eZFileHandler::name ( )
Returns:
the name of current handler.
See also:
identifier

Definition at line 136 of file ezfilehandler.php.

Referenced by eZForwardCompressionHandler\duplicate().

eZFileHandler::open ( filename,
mode,
binaryFile = true 
)

Tries to open the file $filename with mode $mode and returns the file resource if succesful.

Returns:
false if the file could not be opened.
Parameters:
$modeIf false the file will be opened in read mode using 'r'
$binaryFileIf true file will be opened in binary mode (default), otherwise text mode is used.
Note:
Parameter $binaryFile will only have effect on the Windows operating system.

Definition at line 534 of file ezfilehandler.php.

Referenced by rename().

eZFileHandler::passtrough ( closeFile = true)

Passes the data from the file to the standard output.

Parameters:
$closeFileIf true the file will be closed after output is done.
Returns:
false if something failed.

Definition at line 785 of file ezfilehandler.php.

eZFileHandler::read ( length = false)

Reads up to $length bytes from file. Reading stops when $length has been read or EOF is reached, whichever comes first. If the optional parameter $length is not specified it will read bytes until EOF is reached.

Returns:
a string or false if something fails.

Definition at line 646 of file ezfilehandler.php.

eZFileHandler::rename ( destinationFilename,
sourceFilename = false 
)

Renames the file $sourceFilename to $destinationFilename. If $sourceFilename is not supplied then filename() is used, it will also close the current file connection and reopen it again if was already open.

Definition at line 622 of file ezfilehandler.php.

Referenced by doRename().

eZFileHandler::rewind ( )

Rewinds the file position to the beginning of the file.

Returns:
0 if something went wrong.

Definition at line 740 of file ezfilehandler.php.

eZFileHandler::seek ( offset,
whence = SEEK_SET 
)

Seeks to position in file determined by $offset and $whence.

  • SEEK_SET - Set position equal to offset bytes.
  • SEEK_CUR - Set position to current location plus offset.
  • SEEK_END - Set position to end-of-file plus offset. (To move to a position before the end-of-file, you need to pass a negative value in offset.)
Note:
Not all handlers supports all types for $whence
Returns:
0 if succesful or -1 if something failed.

Definition at line 725 of file ezfilehandler.php.

eZFileHandler::statistics ( filename = false)
Returns:
the statitistics for the file $filename.

Definition at line 518 of file ezfilehandler.php.

static eZFileHandler::symlink ( sourceFilename,
destinationFilename 
) [static]

Creates a symbolic link to the file $sourceFilename on the destination $destinationFilename. This means that if someone tries to open $destinationFilename they will infact open $sourceFilename. If $destinationFilename is a directory then the filename is taken from $sourceFilename and appended to the destination. It will first try to rename the file and if that does not work copy the file and unlink.

Returns:
true if sucessful or false if the copy failed.

Definition at line 192 of file ezfilehandler.php.

Referenced by linkCopy().

eZFileHandler::tell ( )

Tells the current file position.

Returns:
false if something failed.

Definition at line 755 of file ezfilehandler.php.

static eZFileHandler::unlink ( filename = false) [static]

Tries to unlink the file from the file system.

Definition at line 601 of file ezfilehandler.php.

Referenced by doUnlink(), link(), move(), and symlink().

eZFileHandler::write ( data,
length = false 
)

Writes the content of the string $data to the file. If optional $length parameter is supplied writing will stop after length is reached or the end of the string is reached, whichever comes first.

Returns:
the number of bytes that was written.

Definition at line 684 of file ezfilehandler.php.


Member Data Documentation

eZFileHandler::$FileName

Definition at line 1095 of file ezfilehandler.php.

eZFileHandler::$IsBinary

Definition at line 1097 of file ezfilehandler.php.

eZFileHandler::$IsOpen

Definition at line 1098 of file ezfilehandler.php.

eZFileHandler::$Mode

Definition at line 1096 of file ezfilehandler.php.

eZFileHandler::$Name

Definition at line 1094 of file ezfilehandler.php.


The documentation for this class was generated from the following file: