/**
* Retrieve the file size of the path
*
* @return mixed
*
* @since 1.7.0
*/
public function filesize()
{
if (!$this->filename) {
$this->setError(Text::_('JLIB_FILESYSTEM_ERROR_STREAMS_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) {
// Something went wrong.
// Store the error in case we need it.
$tmp_error = $php_errormsg;
}
$res = FilesystemHelper::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(Text::_('JLIB_FILESYSTEM_ERROR_STREAMS_FILE_SIZE'));
}
} 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;
}