Implements support for feof().

@return  bool  TRUE if the file pointer is at EOF; otherwise FALSE
185085
public function stream_eof()
	{
		$eof = $this->pos >= strlen($this->data);
		// Workaround for bug in PHP 5.0.x: http://bugs.php.net/27508
		if (version_compare(PHP_VERSION, '5.0', '>=') &&
			version_compare(PHP_VERSION, '5.1', '<')) {

		   $eof = !$eof;
		}
		return $eof;
	}
1145560
public function isFileEmpty()
    {
        $this->openFile();
        $saved_pointer = $this->getFilePointer();
        $this->rewindFile()->seekFileToEnd();
        $size_pointer = $this->getFilePointer();
        $this->seekFile($saved_pointer);

        return $size_pointer === 0;
    }
1008686
public function canRead()
    {
        $ht = $this->getHTaccessFilename();
        $fs = $this->getFilesystem();
        if (@$fs->isFile($ht)) {
            $result = @is_readable($ht);
        } else {
            $result = @is_readable(@dirname($ht));
        }

        return $result;
    }
1077443
public function processFile()
    {
        /** don't reparse the whole file. */
        if (!$this->newFile)
        {
            return true;
        }

        if (!file_exists($this->file))
        {
            echo "<br>Error: File " . ($this->file) . "does not exists!";
            exit;
        }

        $this->debug("Stating Processing of " . $this->newFile, 0, __FILE__, __LINE__);

        $i = 0;
        $exitAll = 0;
        /** Open the JPEG in binary safe reading mode */
        $fp = fopen($this->file, "rb");

        $this->ImageInfo["h"]["FileName"] = $this->file;
        $this->ImageInfo["h"]["FileSize"] = filesize($this->file);
        /** Size of the File */
        $this->ImageInfo["h"]["FileDateTime"] = filectime($this->file);
        /** File node change time */

        /** check whether jped image or not */
        $a = fgetc($fp);
        if (ord($a) != 0xff || ord(fgetc($fp)) != M_SOI)
        {
            $this->debug("Not a JPEG FILE", 1);
            $this->errorno = 1;
            $this->errorstr = "File '" . $this->file . "' is not a JPEG File!";
        }
        $tmpTestLevel = 0;
        /** Examines each byte one-by-one */
        while (!feof($fp))
        {
            $marker = -1;
            for ($a = 0; $a < 7; $a++)
            {
                $marker = fgetc($fp);
                if (ord($marker) != 0xff)
                {
                    break;
                }
                if ($a >= 6)
                {
                    $this->errno = 10;
                    $this->errstr = "too many padding bytes!";
                    $this->debug($this->errstr, 1);
                    return false;
                }
            }

            if (ord($marker) == 0xff)
            {
                // 0xff is legal padding, but if we get that many, something wrong.
                $this->errno = 10;
                $this->errstr = "too many padding bytes!";
                $this->debug($this->errstr, 1);
            }

            $marker = ord($marker);
            $this->sections[$this->currSection]["type"] = $marker;

            // Read the length of the section.
            $lh = ord(fgetc($fp));
            $ll = ord(fgetc($fp));

            $itemLength = ($lh << 8) | $ll;

            if ($itemLength < 2)
            {
                $this->errno = 11;
                $this->errstr = "invalid marker";
                $this->debug($this->errstr, 1);
            }
            $this->sections[$this->currSection]["size"] = $itemLength;

            $tmpDataArr = array();
            /** Temporary Array */

            $tmpStr = fread($fp, $itemLength - 2);
            /*
            $tmpDataArr[] = chr($lh);
            $tmpDataArr[] = chr($ll);

            $chars = preg_split('//', $tmpStr, -1, PREG_SPLIT_NO_EMPTY);
            $tmpDataArr = array_merge($tmpDataArr,$chars);

            $data = $tmpDataArr;
            */
            $data = chr($lh) . chr($ll) . $tmpStr;

            //$this->sections[$this->currSection]["data"] = $data;

            $this->debug("<hr><h1>" . $this->currSection . ":</h1>");
            //print_r($data);
            $this->debug("<hr>");

            //if(count($data) != $itemlen) {
            if (strlen($data) != $itemLength)
            {
                $this->errno = 12;
                $this->errstr = "Premature end of file?";
                $this->debug($this->errstr, 1);
            }

            $this->currSection++;
            /** */

            switch ($marker)
            {
                case M_SOS:
                    $this->debug("<br>Found '" . M_SOS . "' Section, Prcessing it... <br>");;
                    // If reading entire image is requested, read the rest of the data.
                    if ($this->ImageReadMode & $this->ReadMode["READ_IMAGE"])
                    {
                        // Determine how much file is left.
                        $cp = ftell($fp);
                        fseek($fp, 0, SEEK_END);
                        $ep = ftell($fp);
                        fseek($fp, $cp, SEEK_SET);

                        $size = $ep - $cp;
                        $got = fread($fp, $size);

                        $this->sections[$this->currSection]["data"] = $got;
                        $this->sections[$this->currSection]["size"] = $size;
                        $this->sections[$this->currSection]["type"] = PSEUDO_IMAGE_MARKER;
                        $this->currSection++;
                        $HaveAll = 1;
                        $exitAll = 1;
                    }
                    $this->debug("<br>'" . M_SOS . "' Section, PROCESSED<br>");
                    break;
                case M_COM: // Comment section
                    $this->debug("<br>Found '" . M_COM . "'(Comment) Section, Processing<br>");
                    $this->process_COM($data, $itemLength);
                    $this->debug("<br>'" . M_COM . "'(Comment) Section, PROCESSED<br>");

                    $tmpTestLevel++;
                    break;
                case M_SOI:
                    $this->debug(" <br> === START OF IMAGE =====<br>");
                    break;
                case M_EOI:
                    $this->debug(" <br>=== END OF IMAGE =====<br> ");
                    break;
                case M_JFIF:
                    // Regular jpegs always have this tag, exif images have the exif
                    // marker instead, althogh ACDsee will write images with both markers.
                    // this program will re-create this marker on absence of exif marker.
                    // hence no need to keep the copy from the file.
                    //echo " <br> === M_JFIF =====<br>";
                    $this->sections[--$this->currSection]["data"] = "";
                    break;
                case M_EXIF:
                    // Seen files from some 'U-lead' software with Vivitar scanner
                    // that uses marker 31 for non exif stuff.  Thus make sure
                    // it says 'Exif' in the section before treating it as exif.
                    $this->debug("<br>Found '" . M_EXIF . "'(Exif) Section, Proccessing<br>");
                    $this->exifSection = $this->currSection - 1;
                    if (($this->ImageReadMode & $this->ReadMode["READ_EXIF"]) && ($data[2] . $data[3] . $data[4] . $data[5]) == "Exif")
                    {
                        $this->process_EXIF($data, $itemLength);
                    }
                    else
                    {
                        // Discard this section.
                        $this->sections[--$this->currSection]["data"] = "";
                    }
                    $this->debug("<br>'" . M_EXIF . "'(Exif) Section, PROCESSED<br>");
                    $tmpTestLevel++;
                    break;
                case M_SOF0:
                case M_SOF1:
                case M_SOF2:
                case M_SOF3:
                case M_SOF5:
                case M_SOF6:
                case M_SOF7:
                case M_SOF9:
                case M_SOF10:
                case M_SOF11:
                case M_SOF13:
                case M_SOF14:
                case M_SOF15:
                    $this->debug("<br>Found M_SOFn Section, Processing<br>");
                    $this->process_SOFn($data, $marker);
                    $this->debug("<br>M_SOFn Section, PROCESSED<br>");
                    break;
                case M_EXIF_EXT: // 226 - Exif Extended Data
                    $this->debug("<br><b>Found 'Exif Extended Data' Section, Processing</b><br>-------------------------------<br>");
                    $this->process_EXT_EXIF($data, $itemLength);
                    $this->debug("<br>--------------------------PROCESSED<br>");
                    break;

                case M_QUANTA: // 219 - Quantisation Table Definition
                    $this->debug("<br><b>Found 'Quantisation Table Definition' Section, Processing</b><br>-------------------------------<br>");
                    $this->debug("<br>--------------------------PROCESSED<br>");
                    break;

                case M_HUFF: // Huffman Table
                    $this->debug("<br><b>Found 'Huffman Table' Section, Processing</b><br>-------------------------------<br>");
                    $this->debug("<br>--------------------------PROCESSED<br>");
                    break;

                default:
                    $this->debug("DEFAULT: Jpeg section marker 0x$marker x size $itemLength\n");
            }
            $i++;
            if ($exitAll == 1)
            {
                break;
            }
            //if($tmpTestLevel == 2)  break;
        }
        fclose($fp);
        $this->newFile = 0;
        return null;
    }
1046072
public function eof() : bool
    {
        if ($this->closed) {
            throw new IoException('The stream is closed.');
        }

        try {
            return ErrorCatcher::run(function() {
                return feof($this->handle);
            });
        } catch (\ErrorException $e) {
            throw new IoException($e->getMessage(), 0, $e);
        }
    }
506763
public function accept()
    {
        $fileinfo = $this->current();

        foreach ($this->filters as $filter) {
            if (false === $filter($fileinfo)) {
                return false;
            }
        }

        return true;
    }
763879
public function valid() {
		if ($this->string === null) {
			$this->string = fgets($this->file);
		}
		
		return $this->string === false ? false : true;
	}
44308
public function read()
	{
		if( $fcont = @file( $this->uri ) )
		{
			$this->data = array();
			foreach( $fcont as $line )
				$this->data[] = explode( "|", trim( $line ) );
			$this->open	= true;
			return true;
		}
		return false;
	}
920775
public function accept() : bool
    {
        $current = $this->current();

        if (!$this->includeHidden && $current->getFilename(){0} == '.') {
            return false;
        }

        if ($this->fileExtensions && $current->isFile() && !in_array($current->getExtension(), $this->fileExtensions)) {
            return false;
        }
        return true;
    }
435976
public function valid()
    {
        if ($this->fileSize == 0) {
            return false;
        }

        if (feof($this->handle)) {
            return false;
        }

        $current = fgets($this->handle);

        if (trim($current) === '' && feof($this->handle)) {
            return false;
        } else {
            fseek($this->handle, $this->offset);
        }

        return true;
    }
264046
public function accept()
    {
        $fileinfo = $this->current();
        if (!$fileinfo->isFile()) {
            return true;
        }

        $filesize = $fileinfo->getSize();
        foreach ($this->comparators as $compare) {
            if (!$compare->test($filesize)) {
                return false;
            }
        }

        return true;
    }
966193
public function remainingChars() {
        if ($this->char < $this->EOF) {
            $data = substr($this->data, $this->char);
            $this->char = $this->EOF;
            return $data;
        } else {
            return false;
        }
    }
153649
public function accept()
    {
        $file = $this->getInnerIterator()->current();

        // If we somehow have something other than an SplFileInfo object, just
        // return false
        if (!$file instanceof \SplFileInfo) {
            return false;
        }

        // If we have a directory, it's not a file, so return false
        if (!$file->isFile()) {
            return false;
        }

        // If not a PHP file, skip
        if ($file->getBasename('.php') == $file->getBasename()) {
            return false;
        }

        return in_array($this->getExtension(), $this->ext);
    }
730469
public function setPointerPositionToEndOfFile() : bool
   {

      if ( ! \is_resource( $this->fp ) )
      {
         return false;
      }

      return (bool) \fseek( $this->fp, 0, \SEEK_END );

   }
897421
public function accept()
    {
        $filename = $this->current()->getRelativePathname();

        if ('\\' === \DIRECTORY_SEPARATOR) {
            $filename = str_replace('\\', '/', $filename);
        }

        return $this->isAccepted($filename);
    }
355402
public function getPos()
    {
        if ($this->_mode == 0) {
            if (feof($this->file)) {
                $stat = fstat($this->file);
                fseek($this->file, $stat['size']);
            }

            $pos = ftell($this->file);

            return $pos;
        } else {
            return 0;
        }
    }
547540
public function accept()
	{
		$this->numberScanned++;
		if( !parent::accept() )
			return FALSE;
		$this->numberFound++;
		if( !$this->contentPattern )
			return TRUE;
		$filePath	= $this->current()->getPathname();
		$realPath	= realpath( $this->current()->getPathname() );
		if( $realPath )
			$filePath	= $realPath;
		$content	= FS_File_Reader::load( $filePath );
		$found		= preg_match( $this->contentPattern, $content );
		return $found;
	}