Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

Static Public Member Functions | Public Attributes | List of all members
eZFile Class Reference
Utility classes

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 | suffix ( $filename)
static | isWriteable ( $filename)
static | rename ( $srcFile, $destFile, $mkdir=false, $flags=0)
static | download ( $file, $isAttachedDownload=true, $overrideFilename=false, $startOffset=0, $length=false)
static | downloadHeaders ( $file, $isAttachedDownload=true, $overrideFilename=false, $startOffset=0, $length=false, $fileSize=false)
static | downloadContent ( $file, $startOffset=0, $length=false)

## Public Attributes
const | READ_PACKET_SIZE = 16384
const | CLEAN_ON_FAILURE = 1
const | APPEND_DEBUG_ON_FAILURE = 2

## Detailed Description

Tool class which has convencience functions for files and directories.

Definition at line 17 of file ezfile.php.

## Member Function Documentation

## ◆ create()

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

  $atomic | If true the file contents will be written to a temporary file and renamed to the correct file.

Definition at line 41 of file ezfile.php.

References CLEAN_ON_FAILURE, eZDir\mkdir(), and rename().

Referenced by eZPackage\appendDocument(), eZMutex\clearMeta(), eZFSFileHandler\fileStoreContents(), eZFileTransport\sendMail(), eZMutex\setMeta(), and eZFSFileHandler\storeContents().

## ◆ download()

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 | $file | Path to the local file
  bool | $isAttachedDownload | Determines weather to download the file as an attachment ( download popup box ) or not.
  string | $overrideFilename |
  int | $startOffset | Offset to start transfer from, in bytes
  int | $length | Data size to transfer

Returns
  bool false if error

Definition at line 193 of file ezfile.php.

References eZExecution\cleanExit(), downloadContent(), and downloadHeaders().

## ◆ downloadContent()

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 | $file | Path to the local file
  int | $startOffset | Offset to start transfer from, in bytes
  int | $length | Data size to transfer

Definition at line 277 of file ezfile.php.

References READ_PACKET_SIZE, and eZDebug\writeError().

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

## ◆ downloadHeaders()

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 | $file | Path to the local file
  bool | $isAttachedDownload | Determines weather to download the file as an attachment ( download popup box ) or not.
  string | $overrideFilename | Filename to send in headers instead of the actual file's name
  int | $startOffset | Offset to start transfer from, in bytes
  int | $length | Data size to transfer
  string | $fileSize | The file's size. If not given, actual filesize will be queried. Required to work with clusterized files...

Definition at line 220 of file ezfile.php.

References eZMimeType\findByURL(), and eZDebug\writeError().

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

## ◆ isWriteable()

static eZFile::isWriteable | ( |  | $filename | ) |
| static

Check if a given file is writeable

Returns
  TRUE/FALSE

Definition at line 114 of file ezfile.php.

References eZSys\osType().

## ◆ rename()

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 | $srcFile | Source file path
  string | $destFile | Destination file path
  bool | $mkdir | Make directory for destination file if needed
  int | $flags | Supported 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 152 of file ezfile.php.

References eZDir\mkdir(), and eZDebug\writeWarning().

Referenced by create(), eZFileHandler\doRename(), eZFSFileHandler\fileMove(), eZFileHandler\move(), eZSubtreeCache\renameDir(), eZLog\rotateLog(), eZDebug\rotateLog(), and eZStaticCache\storeCachedFile().

## ◆ suffix()

static eZFile::suffix | ( |  | $filename | ) |
| static

Get suffix from filename

Parameters

  filename |

Returns
  suffix, extends: file/to/readme.txt return txt

Definition at line 102 of file ezfile.php.

Referenced by eZPackage\appendSimpleFile(), eZTSTranslator\fetchList(), eZBinaryFileType\fetchObjectAttributeHTTPInput(), eZMediaType\fetchObjectAttributeHTTPInput(), eZBinaryFileType\insertRegularFile(), eZMediaType\insertRegularFile(), eZBinaryFileType\trashStoredObjectAttribute(), eZMediaType\trashStoredObjectAttribute(), eZBinaryFileType\unserializeContentObjectAttribute(), and eZMediaType\unserializeContentObjectAttribute().

## Member Data Documentation

## ◆ APPEND_DEBUG_ON_FAILURE

const eZFile::APPEND_DEBUG_ON_FAILURE = 2

Definition at line 32 of file ezfile.php.

Referenced by eZSubtreeCache\renameDir(), and eZStaticCache\storeCachedFile().

## ◆ CLEAN_ON_FAILURE

const eZFile::CLEAN_ON_FAILURE = 1

Flags for file manipulation

See also
  rename()

Definition at line 31 of file ezfile.php.

Referenced by create(), and eZStaticCache\storeCachedFile().

## ◆ READ_PACKET_SIZE

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:

- ezfile.php

Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.