API16:JStream/close
From Joomla! Documentation
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
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;
}
Examples
Code Examples