eZPublishCommunityProject(LegacyStack)  2013.9
eZFile Class Reference

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

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. More...
 
static downloadContent ($file, $startOffset=0, $length=false)
 Handles the data part of a file transfer to the client. More...
 
static downloadHeaders ($file, $isAttachedDownload=true, $overrideFilename=false, $startOffset=0, $length=false, $fileSize=false)
 Handles the header part of a file transfer to the client. More...
 
static isWriteable ($filename)
 
static rename ($srcFile, $destFile, $mkdir=false, $flags=0)
 Renames $srcFile to $destFile atomically on Unix, and provides a workaround for Windows. More...
 
static suffix ($filename)
 

Public Attributes

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

Detailed Description

Tool class which has convencience functions for files and directories.

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.

Referenced by eZPackage\appendDocument(), eZMutex\clearMeta(), eZDFSFileHandlerDFSBackend\createFile(), eZStepSiteTypes\downloadFile(), eZFSFileHandler\fileStoreContents(), eZFileTransport\sendMail(), eZMutex\setMeta(), eZDFSFileHandler\storeCache(), 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
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

Referenced by 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...

Referenced by eZFilePassthroughHandler\handleFileDownload().

static eZFile::isWriteable (   $filename)
static

Check if a given file is writeable

Returns
TRUE/FALSE

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)

Referenced by eZDFSFileHandlerMySQLiBackend\_fetch(), eZPHPCreator\close(), create(), eZFileHandler\doRename(), eZFSFileHandler\fileMove(), eZFileHandler\move(), eZSubtreeCache\renameDir(), eZDFSFileHandlerDFSBackend\renameOnDFS(), eZLog\rotateLog(), eZDebug\rotateLog(), eZINI\saveCache(), and eZStaticCache\storeCachedFile().

Member Data Documentation

const eZFile::APPEND_DEBUG_ON_FAILURE = 2
const eZFile::CLEAN_ON_FAILURE = 1
const eZFile::READ_PACKET_SIZE = 16384

Number of bytes read per fread() operation.

See Also
downloadContent()

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