Horde_Vfs_Base::_checkQuotaWrite PHP Метод

_checkQuotaWrite() защищенный Метод

Checks the quota when preparing to write data.
protected _checkQuotaWrite ( string $mode, string $data, string $path = null, string $name = null )
$mode string Either 'string' or 'file'. If 'string', $data is the data to be written. If 'file', $data is the filename containing the data to be written.
$data string Either the data or the filename to the data.
$path string The path the file is located in.
$name string The filename.
    protected function _checkQuotaWrite($mode, $data, $path = null, $name = null)
    {
        if ($this->_params['vfs_quotalimit'] == -1 && is_null($this->_vfsSize)) {
            return;
        }
        if ($mode == 'file') {
            $filesize = filesize($data);
            if ($filesize === false) {
                throw new Horde_Vfs_Exception('Unable to read VFS file (filesize() failed).');
            }
        } else {
            $filesize = strlen($data);
        }
        $oldsize = 0;
        if ($name) {
            try {
                $oldsize = $this->size($path, $name);
            } catch (Horde_Vfs_Exception $e) {
            }
        }
        $vfssize = $this->getVFSSize();
        if ($this->_params['vfs_quotalimit'] > -1 && $vfssize + $filesize - $oldsize > $this->_params['vfs_quotalimit']) {
            throw new Horde_Vfs_Exception('Unable to write VFS file, quota will be exceeded.');
        }
        if (!is_null($this->_vfsSize)) {
            $this->_vfsSize += $filesize - $oldsize;
        }
    }