Exponential Basic 2.4.0.1 Exponential Basic 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...

Inheritance diagram for eZFile:

## 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 18 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 42 of file ezfile.php.

References $file, CLEAN_ON_FAILURE, file_exists(), eZDir\mkdir(), and rename().

Referenced by eZDFSFileHandlerDFSBackend\createFile(), eZFSFileHandler\fileStoreContents(), eZDFSFileHandler\storeCache(), eZFSFileHandler\storeContents(), and eZDFSFileHandler\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 194 of file ezfile.php.

References $file, eZExecution\cleanExit(), downloadContent(), downloadHeaders(), file_exists(), and eZSession\stop().

## ◆ 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 278 of file ezfile.php.

References $file, $fileSize, $fp, file_exists(), READ_PACKET_SIZE, and eZDebug\writeError().

Referenced by download(), eZDFSFileHandlerDFSBackend\passthrough(), 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 221 of file ezfile.php.

References $file, $fileSize, file_exists(), and eZDebug\writeError().

Referenced by download().

## ◆ isWriteable()

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

Check if a given file is writeable

Returns
  TRUE/FALSE

Definition at line 115 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 153 of file ezfile.php.

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

Referenced by eZDFSFileHandlerMySQLiBackend\_fetch(), create(), eZFileHandler\doRename(), eZFSFileHandler\fileMove(), eZFileHandler\move(), eZDFSFileHandlerDFSBackend\renameOnDFS(), eZLog\rotateLog(), and eZDebug\rotateLog().

## ◆ suffix()

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

Get suffix from filename

Parameters

  filename |

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

Definition at line 103 of file ezfile.php.

Referenced by eZTSTranslator\fetchList(), and eZWebDAVContentBackend\fetchNodeInfo().

## Member Data Documentation

## ◆ APPEND_DEBUG_ON_FAILURE

const eZFile::APPEND_DEBUG_ON_FAILURE = 2

Definition at line 33 of file ezfile.php.

Referenced by eZDFSFileHandlerMySQLiBackend\_fetch().

## ◆ CLEAN_ON_FAILURE

const eZFile::CLEAN_ON_FAILURE = 1

Flags for file manipulation

See also
  rename()

Definition at line 32 of file ezfile.php.

Referenced by eZDFSFileHandlerMySQLiBackend\_fetch(), and create().

## ◆ READ_PACKET_SIZE

const eZFile::READ_PACKET_SIZE = 16384

Number of bytes read per fread() operation.

See also
  downloadContent()

Definition at line 25 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+.