eZ Publish Community Project (Legacy Stack) 2013.4
Class

eZFSFileHandler

class eZFSFileHandler

File containing the eZFSFileHandler class.

Constants

EXPIRY_TIMESTAMP

Properties

$metaData
$filePath

Methods

eZFSFileHandler($filePath = false)

Constructor.

_exclusiveLock($fname = false)

_freeExclusiveLock($fname = false)

_mutex()

loadMetaData($force = false)

fileFetch($filePath)

Fetches file from db and saves it in FS under the same name.

fetch($noLocalCache = false)

Fetches file from db and saves it in FS under the same name.

string fetchUnique()

Fetches file from db and saves it in FS under unique name.

fileStore($filePath, $scope = false, $delete = false, $datatype = false)

Store file.

fileStoreContents($filePath, $contents, $scope = false, $datatype = false)

Store file contents.

void storeContents($contents, $scope = false, $datatype = false, $storeLocally = false)

Store file contents to disk

string|false fileFetchContents($filePath)

Returns file contents.

fetchContents()

Returns file contents.

processCache($retrieveCallback, $generateCallback = null, $ttl = null, $expiry = null, $extraData = null)

static bool isFileExpired(string $fname, int $mtime, int $expiry, int $curtime, int $ttl)

Calculates if the file data is expired or not.

bool isExpired(int $expiry, int $curtime, int $ttl)

Calculates if the current file data is expired or not.

storeCache($fileData, $storeCache = true)

processFile($callback, $expiry = false, $extraData = null)

stat()

Returns file metadata.

size()

Returns file size.

mtime()

Returns file modification time.

name()

Returns file name.

fileDeleteByWildcard($wildcard)

Delete files matching given wildcard.

fileDeleteByDirList($dirList, $commonPath, $commonSuffix)

Delete files located in a directories from dirList, with common prefix specified by commonPath, and common suffix with added wildcard at the end

fileDelete($path, $fnamePart = false)

\public \static

delete()

Deletes specified file/directory.

fileDeleteLocal($path)

Deletes a file that has been fetched before.

deleteLocal()

Deletes a file that has been fetched before.

purge($printCallback = false, $microsleep = false, $max = false, $expiry = false)

fileExists($path)

Check if given file/dir exists.

exists()

Check if given file/dir exists.

passthrough(int $offset, int $length = false)

Outputs file contents to the browser Note: does not handle headers.

fileCopy($srcPath, $dstPath)

Copy file.

fileLinkCopy($srcPath, $dstPath, $symLink)

Create symbolic or hard link to file.

fileMove($srcPath, $dstPath)

Move file.

move($dstPath)

Move file.

mixed startCacheGeneration()

Starts cache generation for the current file.

endCacheGeneration()

Ends the cache generation started by startCacheGeneration().

abortCacheGeneration()

Aborts the current cache generation process.

checkCacheGenerationTimeout()

Checks if the .generating file was changed, which would mean that generation timed out.

bool requiresClusterizing()

eZFS only stores data to FS and doesn't require/support clusterizing

bool requiresPurge()

eZFS does not require binary purge.

hasStaleCacheSupport()

Details

at line 20
public eZFSFileHandler($filePath = false)

Constructor.

$filePath File path. If specified, file metadata is fetched in the constructor.

Parameters

$filePath

at line 40
public _exclusiveLock($fname = false)

Parameters

$fname

at line 85
public _freeExclusiveLock($fname = false)

Parameters

$fname

at line 95
public _mutex()

at line 109
public loadMetaData($force = false)

Parameters

$force

at line 130
public fileFetch($filePath)

Fetches file from db and saves it in FS under the same name.

In case of fetching from filesystem does nothing.

Parameters

$filePath

at line 141
public fetch($noLocalCache = false)

Fetches file from db and saves it in FS under the same name.

In case of fetching from filesystem does nothing.

Parameters

$noLocalCache

at line 154
public string fetchUnique()

Fetches file from db and saves it in FS under unique name.

In case of fetching from filesystem, does nothing

Return Value

string The unique file path. on FS, the file path.

at line 169
public fileStore($filePath, $scope = false, $delete = false, $datatype = false)

Store file.

In case of storing to filesystem does nothing.

Parameters

$filePath
$scope
$delete
$datatype

at line 180
public fileStoreContents($filePath, $contents, $scope = false, $datatype = false)

Store file contents.

\public \static

Parameters

$filePath
$contents
$scope
$datatype

at line 204
public void storeContents($contents, $scope = false, $datatype = false, $storeLocally = false)

Store file contents to disk

Parameters

$contents
$scope
$datatype
$storeLocally

Return Value

void

at line 224
public string|false fileFetchContents($filePath)

Returns file contents.

Parameters

$filePath

Return Value

string|false contents string, or false in case of an error.

at line 241
public fetchContents()

Returns file contents.

\public \return contents string, or false in case of an error.

at line 298
public processCache($retrieveCallback, $generateCallback = null, $ttl = null, $expiry = null, $extraData = null)

Parameters

$retrieveCallback
$generateCallback
$ttl
$expiry
$extraData

at line 420
static public bool isFileExpired(string $fname, int $mtime, int $expiry, int $curtime, int $ttl)

Calculates if the file data is expired or not.

Parameters

string $fname Name of file, available for easy debugging.
int $mtime Modification time of file, can be set to false if file does not exist.
int $expiry Time when file is to be expired, a value of -1 will disable this check.
int $curtime The current time to check against.
int $ttl Number of seconds the data can live, set to null to disable TTL.

Return Value

bool

at line 450
public bool isExpired(int $expiry, int $curtime, int $ttl)

Calculates if the current file data is expired or not.

Parameters

int $expiry Time when file is to be expired, a value of -1 will disable this check.
int $curtime The current time to check against.
int $ttl Number of seconds the data can live, set to null to disable TTL.

Return Value

bool

at line 468
public storeCache($fileData, $storeCache = true)

Parameters

$fileData
$storeCache

at line 540
public processFile($callback, $expiry = false, $extraData = null)

Parameters

$callback
$expiry
$extraData

at line 555
public stat()

Returns file metadata.

\public

at line 566
public size()

Returns file size.

\public

at line 578
public mtime()

Returns file modification time.

\public

at line 590
public name()

Returns file name.

\public

at line 602
public fileDeleteByWildcard($wildcard)

Delete files matching given wildcard.

\public \static

Parameters

$wildcard

at line 623
public fileDeleteByDirList($dirList, $commonPath, $commonSuffix)

Delete files located in a directories from dirList, with common prefix specified by commonPath, and common suffix with added wildcard at the end

\public \static

Parameters

$dirList
$commonPath
$commonSuffix

at line 645
public fileDelete($path, $fnamePart = false)

\public \static

Parameters

$path
$fnamePart

at line 691
public delete()

Deletes specified file/directory.

If a directory specified it is deleted recursively.

\public \static

at line 725
public fileDeleteLocal($path)

Deletes a file that has been fetched before.

Parameters

$path

See also

fetchUnique In case of fetching from filesystem does nothing.

at line 737
public deleteLocal()

Deletes a file that has been fetched before.

In case of fetching from filesystem does nothing.

\public

at line 746
public purge($printCallback = false, $microsleep = false, $max = false, $expiry = false)

Parameters

$printCallback
$microsleep
$max
$expiry

at line 806
public fileExists($path)

Check if given file/dir exists.

\public \static

Parameters

$path

at line 825
public exists()

Check if given file/dir exists.

NOTE: this function does not interact with filesystem. Instead, it just returns existance status determined in the constructor.

\public

at line 840
public passthrough(int $offset, int $length = false)

Outputs file contents to the browser Note: does not handle headers.

eZFile::downloadHeaders() can be used for this

Parameters

int $offset Transfer start offset
int $length Transfer length, in bytes

at line 856
public fileCopy($srcPath, $dstPath)

Copy file.

\public \static

Parameters

$srcPath
$dstPath

at line 871
public fileLinkCopy($srcPath, $dstPath, $symLink)

Create symbolic or hard link to file.

\public \static

Parameters

$srcPath
$dstPath
$symLink

at line 886
public fileMove($srcPath, $dstPath)

Move file.

\public \static

Parameters

$srcPath
$dstPath

at line 900
public move($dstPath)

Move file.

\public

Parameters

$dstPath

at line 922
public mixed startCacheGeneration()

Starts cache generation for the current file.

This is done by creating a file named by the original file name, prefixed with '.generating'.

Return Value

mixed true if generation lock was granted, an integer matching the time before the current generation times out

at line 930
public endCacheGeneration()

Ends the cache generation started by startCacheGeneration().

at line 941
public abortCacheGeneration()

Aborts the current cache generation process.

Does so by rolling back the current transaction, which should be the .generating file lock

at line 951
public checkCacheGenerationTimeout()

Checks if the .generating file was changed, which would mean that generation timed out.

If not timed out, refreshes the timestamp so that storage won't be stolen

at line 961
public bool requiresClusterizing()

eZFS only stores data to FS and doesn't require/support clusterizing

Return Value

bool false

at line 973
public bool requiresPurge()

eZFS does not require binary purge.

Files are stored on plain FS and removed using FS functions

Return Value

bool

at line 978
public hasStaleCacheSupport()