API16:JStream/filesize
From Joomla! Documentation
Description
Retrieve the file size of the path
Syntax
filesize()
Defined in
libraries/joomla/filesystem/stream.php
Importing
jimport( 'joomla.filesystem.stream' );
Source Body
function filesize()
{
if(!$this->filename)
{
$this->setError(JText::_('File not open'));
return false;
}
$retval = false;
// Capture PHP errors
$php_errormsg = '';
$track_errors = ini_get('track_errors');
ini_set('track_errors', true);
$res = @filesize($this->filename);
if(!$res)
{
$tmp_error = '';
if($php_errormsg) { // some bad went wrong
$tmp_error = $php_errormsg; // store the error in case we need it
}
$res = JFilesystemHelper::remotefsize($this->filename);
if(!$res)
{
if($tmp_error) { // use the php_errormsg from before
$this->setError($tmp_error);
} else { // error but nothing from php? how strange! create our own
$this->setError(JText::_('Failed to get file size. This may not work for all streams!'));
}
}
else
{
$this->_filesize = $res;
$retval = $res;
}
}
else
{
$this->_filesize = $res;
$retval = $res;
}
// restore error tracking to what it was before
ini_set('track_errors',$track_errors);
// return the result
return $retval;
}
Examples
Code Examples