Back to FileStorage class

Method __construct

public
__construct
(mixed $options = array())
Constructor
Parameters
  • array $options Optional parameters
Since
  • 1.7.0
Class: FileStorage
Project: Joomla

Method __construct - Source code

/**
 * Constructor
 *
 * @param   array  $options  Optional parameters
 *
 * @since   1.7.0
 */
public function __construct($options = array())
{
    parent::__construct($options);
    $this->_root = $options['cachebase'];
    // Workaround for php 5.3
    $locked_files =& $this->_locked_files;
    // Remove empty locked files at script shutdown.
    $clearAtShutdown = function () use(&$locked_files) {
        foreach ($locked_files as $path => $handle) {
            if (\is_resource($handle)) {
                @flock($handle, LOCK_UN);
                @fclose($handle);
            }
            // Delete only the existing file if it is empty.
            if (@filesize($path) === 0) {
                File::invalidateFileCache($path);
                @unlink($path);
            }
            unset($locked_files[$path]);
        }
    };
    register_shutdown_function($clearAtShutdown);
}