eZ Publish  [trunk]
eZFile Class Reference

Tool class which has convencience functions for files and directories. More...

List of all members.

Static Public Member Functions

static create ($filename, $directory=false, $data=false, $atomic=false)
static download ($file, $isAttachedDownload=true, $overrideFilename=false, $startOffset=0, $length=false)
 Prepares a file for Download and terminates the execution.
static downloadContent ($file, $startOffset=0, $length=false)
 Handles the data part of a file transfer to the client.
static downloadHeaders ($file, $isAttachedDownload=true, $overrideFilename=false, $startOffset=0, $length=false, $fileSize=false)
 Handles the header part of a file transfer to the client.
static getContents ($filename)
static isWriteable ($filename)
static rename ($srcFile, $destFile, $mkdir=false, $flags=0)
 Renames $srcFile to $destFile atomically on Unix, and provides a workaround for Windows.
static splitLines ($file)
 Reads the whole contents of the file $file and splits it into lines which is collected into an array and returned.
static suffix ($filename)

Public Attributes

const APPEND_DEBUG_ON_FAILURE = 2
const CLEAN_ON_FAILURE = 1
 Flags for file manipulation.
const READ_PACKET_SIZE = 16384
 Number of bytes read per fread() operation.

Detailed Description

Tool class which has convencience functions for files and directories.

Definition at line 17 of file ezfile.php.


Member Function Documentation

static eZFile::create ( filename,
directory = false,
data = false,
atomic = false 
) [static]

Creates a file called $filename. If $directory is specified the file is placed there, the directory will also be created if missing. if $data is specified the file will created with the content of this variable.

Parameters:
$atomicIf true the file contents will be written to a temporary file and renamed to the correct file.

Definition at line 60 of file ezfile.php.

Referenced by eZMutex\clearMeta(), eZDFSFileHandlerDFSBackend\createFile(), eZStepSiteTypes\downloadFile(), eZFSFileHandler\fileStoreContents(), eZFileTransport\sendMail(), eZMutex\setMeta(), eZDBFileHandler\storeCache(), eZDFSFileHandler\storeCache(), eZDBFileHandler\storeContents(), eZFSFileHandler\storeContents(), and eZDFSFileHandler\storeContents().

static eZFile::download ( file,
isAttachedDownload = true,
overrideFilename = false,
startOffset = 0,
length = false 
) [static]

Prepares a file for Download and terminates the execution.

This method will:

  • empty the output buffer
  • stop buffering
  • stop the active session (in order to allow concurrent browsing while downloading)
Parameters:
string$filePath to the local file
bool$isAttachedDownloadDetermines weather to download the file as an attachment ( download popup box ) or not.
string$overrideFilename
int$startOffsetOffset to start transfer from, in bytes
int$lengthData size to transfer
Returns:
bool false if error

Definition at line 231 of file ezfile.php.

static eZFile::downloadContent ( file,
startOffset = 0,
length = false 
) [static]

Handles the data part of a file transfer to the client.

See also:
download()
Parameters:
string$filePath to the local file
int$startOffsetOffset to start transfer from, in bytes
int$lengthData size to transfer

Definition at line 315 of file ezfile.php.

Referenced by download(), eZDFSFileHandlerDFSBackend\passthrough(), and eZFSFileHandler\passthrough().

static eZFile::downloadHeaders ( file,
isAttachedDownload = true,
overrideFilename = false,
startOffset = 0,
length = false,
fileSize = false 
) [static]

Handles the header part of a file transfer to the client.

See also:
download()
Parameters:
string$filePath to the local file
bool$isAttachedDownloadDetermines weather to download the file as an attachment ( download popup box ) or not.
string$overrideFilenameFilename to send in headers instead of the actual file's name
int$startOffsetOffset to start transfer from, in bytes
int$lengthData size to transfer
string$fileSizeThe file's size. If not given, actual filesize will be queried. Required to work with clusterized files...

Definition at line 258 of file ezfile.php.

Referenced by download(), and eZFilePassthroughHandler\handleFileDownload().

static eZFile::getContents ( filename) [static]

Read all content of file.

Parameters:
filename
Returns:
file contents, false if error
Deprecated:
since eZ Publish 4.1, use file_get_contents() instead

Definition at line 112 of file ezfile.php.

static eZFile::isWriteable ( filename) [static]

Check if a given file is writeable

Returns:
TRUE/FALSE

Definition at line 152 of file ezfile.php.

Referenced by eZSetupPrvtAreDirAndFilesWritable(), and eZSetupTestFilePermissions().

static eZFile::rename ( srcFile,
destFile,
mkdir = false,
flags = 0 
) [static]

Renames $srcFile to $destFile atomically on Unix, and provides a workaround for Windows.

Usage example: $srcFile = '/path/to/src/file'; $destFile = '/path/to/dest/file'; eZFile::rename( $srcFile, $destFile );

// Using flags // In following example, if rename operation fails, $srcFile will be deleted and a message will be appended in eZDebug eZFile::rename( $srcFile, $destFile, false, eZFile::APPEND_DEBUG_ON_FAILURE | eZFile::CLEAN_ON_FAILURE );

Parameters:
string$srcFileSource file path
string$destFileDestination file path
bool$mkdirMake directory for destination file if needed
int$flagsSupported flags are :
  • APPEND_DEBUG_ON_FAILURE (will append a message to the debug if operation fails
  • CLEAN_ON_FAILURE (Will remove $srcFile if operation fails)
Returns:
bool rename() status (true if successful, false if not)

Definition at line 190 of file ezfile.php.

Referenced by eZDBFileHandlerMysqliBackend\_fetch(), eZDBFileHandlerMysqlBackend\_fetch(), eZDFSFileHandlerMySQLBackend\_fetch(), eZDFSFileHandlerMySQLiBackend\_fetch(), eZPHPCreator\close(), create(), eZFS2FileHandler\endCacheGeneration(), eZFileHandler\move(), eZWebDAVFileServer\move(), eZWebDAVFileServer\put(), eZSubtreeCache\renameDir(), eZDFSFileHandlerDFSBackend\renameOnDFS(), eZLog\rotateLog(), eZDebug\rotateLog(), eZINI\saveCache(), and eZStaticCache\storeCachedFile().

static eZFile::splitLines ( file) [static]

Reads the whole contents of the file $file and splits it into lines which is collected into an array and returned.

It will handle Unix (
), Windows (
) and Mac () style newlines.

Note:
The newline character(s) are not present in the line string.
Deprecated:
Since 4.4, use file( $file, FILE_IGNORE_NEW_LINES ) instead.
Returns:
array|false

Definition at line 43 of file ezfile.php.


Member Data Documentation

const eZFile::READ_PACKET_SIZE = 16384

Number of bytes read per fread() operation.

See also:
downloadContent()

Definition at line 24 of file ezfile.php.

Referenced by downloadContent().


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