Actions

API16

JStream/close

From Joomla! Documentation

< API16:JStream
Revision as of 17:47, 22 March 2010 by Doxiki (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

Description

Attempt to close a file handle Will return false if it failed and true on success Note: if the file is not open the system will return true Note: this function destroys the file handle as well

[Edit Descripton]

Description:JStream/close

Syntax

close()


Defined in

libraries/joomla/filesystem/stream.php

Importing

jimport( 'joomla.filesystem.stream' );

Source Body

function close()
{
        if(!$this->_fh)
        {
                $this->setError(JText::_('File not open'));
                return true;
        }
        $retval = false;
        // Capture PHP errors
        $php_errormsg = 'Error Unknown';
        $track_errors = ini_get('track_errors');
        ini_set('track_errors', true);
        switch($this->processingmethod)
        {
                case 'gz':
                        $res = gzclose($this->_fh);
                        break;
                case 'bz':
                        $res = bzclose($this->_fh);
                        break;
                case 'f':
                default:
                        $res = fclose($this->_fh);
                        break;
        }
 
 
        if(!$res) {
                $this->setError($php_errormsg);
        }
        else
        {
                $this->_fh = null; // reset this
                $retval = true;
        }
        // chmod the file after its closed if we wrote
        if($this->_openmode[0] == 'w') {
                $this->chmod();
        }
        // restore error tracking to what it was before
        ini_set('track_errors',$track_errors);
        // return the result
        return $retval;
}

[Edit See Also] SeeAlso:JStream/close

Examples

<CodeExamplesForm />