$amount) { $chunksize = $amount; } if (false === $fh = fopen($filename, 'rb', $incpath)) { JError::raiseWarning(21, 'extFile::read: '.JText::_('Unable to open file') . ": '$filename'"); return false; } clearstatcache(); if($offset) fseek($fh, $offset); if ($fsize = @ filesize($filename)) { if($amount && $fsize > $amount) { $data = fread($fh, $amount); } else { $data = fread($fh, $fsize); } } else { $data = ''; $x = 0; // While its: // 1: Not the end of the file AND // 2a: No Max Amount set OR // 2b: The length of the data is less than the max amount we want while (!feof($fh) && (!$amount || strlen($data) < $amount)) { $data .= fread($fh, $chunksize); } } fclose($fh); return $data; } /** * Wrapper for the standard file_exists function * * @param string $file File path * @return boolean True if path is a file * @since 1.5 */ static function exists($file) { return is_file(extPath::clean($file)); } /** * Returns the name, sans any path * * param string $file File path * @return string filename * @since 1.5 */ static function getName($file) { $slash = strrpos($file, DS); if ($slash !== false) { return substr($file, $slash + 1); } else { return $file; } } }