Changeset 1622
- Timestamp:
- 06/12/08 13:52:26 (4 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/streams/stubFileInputStream.php
r1605 r1622 19 19 { 20 20 /** 21 * name of the file 22 * 23 * @var string 24 */ 25 protected $fileName; 26 27 /** 21 28 * constructor 22 29 * … … 27 34 { 28 35 if (is_string($file) === true) { 29 $fp = fopen($file, $mode); 36 $fp = fopen($file, $mode); 37 $this->fileName = $file; 30 38 } elseif (is_resource($file) === true) { 31 39 $fp = $file; … … 44 52 $this->close(); 45 53 } 54 55 /** 56 * helper method to retrieve the length of the resource 57 * 58 * Not all stream wrappers support (f)stat - the extending class then 59 * needs to take care to deliver the correct resource length then. 60 * 61 * @return int 62 */ 63 protected function getResourceLength() 64 { 65 if (null === $this->fileName) { 66 return parent::getResourceLength(); 67 } 68 69 if (substr($this->fileName, 0, 16) === 'compress.zlib://') { 70 return filesize(substr($this->fileName, 16)); 71 } elseif (substr($this->fileName, 0, 17) === 'compress.bzip2://') { 72 return filesize(substr($this->fileName, 17)); 73 } 74 } 46 75 } 47 76 ?> trunk/src/main/php/net/stubbles/streams/stubResourceInputStream.php
r1552 r1622 103 103 } 104 104 105 return $this->getResourceLength() - $bytesRead; 106 } 107 108 /** 109 * helper method to retrieve the length of the resource 110 * 111 * Not all stream wrappers support (f)stat - the extending class then 112 * needs to take care to deliver the correct resource length then. 113 * 114 * @return int 115 */ 116 protected function getResourceLength() 117 { 105 118 $fileData = fstat($this->handle); 106 return $fileData['size'] - $bytesRead;119 return $fileData['size']; 107 120 } 108 121
