Changeset 1755
- Timestamp:
- 07/31/08 17:24:46 (4 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
framework/trunk/src/main/php/net/stubbles/streams/stubInputStream.php
r1552 r1755 39 39 40 40 /** 41 * returns true if the stream pointer is at EOF 42 * 43 * @return bool 44 */ 45 public function eof(); 46 47 /** 41 48 * closes the stream 42 49 */ framework/trunk/src/main/php/net/stubbles/streams/stubResourceInputStream.php
r1622 r1755 38 38 throw new stubIllegalArgumentException('Handle needs to be a stream resource.'); 39 39 } 40 40 41 41 $this->handle = $handle; 42 42 } … … 55 55 throw new stubIllegalStateException('Can not read from closed input stream.'); 56 56 } 57 57 58 58 $data = @fread($this->handle, $length); 59 59 if (false === $data) { 60 60 throw new stubIOException('Can not read from input stream.'); 61 61 } 62 62 63 63 return $data; 64 64 } … … 77 77 throw new stubIllegalStateException('Can not read from closed input stream.'); 78 78 } 79 79 80 80 $data = @fgets($this->handle, $length); 81 81 if (false === $data) { 82 82 throw new stubIOException('Can not read from input stream.'); 83 83 } 84 84 85 85 return rtrim($data, "\r\n"); 86 86 } … … 97 97 throw new stubIllegalStateException('Can not read from closed input stream.'); 98 98 } 99 99 100 100 $bytesRead = ftell($this->handle); 101 101 if (is_int($bytesRead) === false) { 102 102 return 0; 103 103 } 104 104 105 105 return $this->getResourceLength() - $bytesRead; 106 } 107 108 /** 109 * returns true if the stream pointer is at EOF 110 * 111 * @return bool 112 */ 113 public function eof() 114 { 115 return feof($this->handle); 106 116 } 107 117 framework/trunk/src/test/php/net/stubbles/streams/stubResourceInputStreamTestCase.php
r1703 r1755 105 105 106 106 /** 107 * check end of file pointer 108 * 109 * @test 110 */ 111 public function endOfFile() 112 { 113 $this->assertFalse($this->resourceInputStream->eof()); 114 $this->resourceInputStream->read(); 115 $this->assertTrue($this->resourceInputStream->eof()); 116 } 117 118 /** 107 119 * trying to read fails after resource was closed 108 120 *
