| | $offset, |
| | $cap, |
| | - $pool, |
| | - $packFile, |
| | $readShaBaseFn |
| | ): string { |
| | - fseek( $handle, $offset ); |
| | + return $this->readWithHandle( |
| | + $handle, |
| | + $offset, |
| | + $cap, |
| | + $readShaBaseFn |
| | + ); |
| | + }, |
| | + '' |
| | + ); |
| | + } |
| | |
| | - $header = $this->readVarInt( $handle ); |
| | - $type = $header['byte'] >> 4 & 7; |
| | - $result = ''; |
| | + private function readWithHandle( |
| | + mixed $handle, |
| | + int $offset, |
| | + int $cap, |
| | + callable $readShaBaseFn |
| | + ): string { |
| | + fseek( $handle, $offset ); |
| | |
| | - if( $type === 6 ) { |
| | - $neg = $this->readOffsetDelta( $handle ); |
| | - $cur = ftell( $handle ); |
| | - $base = $offset - $neg; |
| | - $bData = $this->read( |
| | - $pool, |
| | - $packFile, |
| | - $base, |
| | - $cap, |
| | - $readShaBaseFn |
| | - ); |
| | + $header = $this->readVarInt( $handle ); |
| | + $type = $header['byte'] >> 4 & 7; |
| | + $result = ''; |
| | |
| | - fseek( $handle, $cur ); |
| | + if( $type === 6 ) { |
| | + $neg = $this->readOffsetDelta( $handle ); |
| | + $cur = ftell( $handle ); |
| | + $base = $offset - $neg; |
| | + $bData = $this->readWithHandle( |
| | + $handle, |
| | + $base, |
| | + $cap, |
| | + $readShaBaseFn |
| | + ); |
| | |
| | - $delta = $this->inflate( $handle ); |
| | - $result = $this->decoder->apply( $bData, $delta, $cap ); |
| | - } elseif( $type === 7 ) { |
| | - $sha = bin2hex( fread( $handle, 20 ) ); |
| | - $bas = $readShaBaseFn( $sha, $cap ); |
| | - $del = $this->inflate( $handle ); |
| | - $result = $this->decoder->apply( $bas, $del, $cap ); |
| | - } else { |
| | - $result = $this->inflate( $handle, $cap ); |
| | - } |
| | + fseek( $handle, $cur ); |
| | |
| | - return $result; |
| | - }, |
| | - '' |
| | - ); |
| | + $delta = $this->inflate( $handle ); |
| | + $result = $this->decoder->apply( $bData, $delta, $cap ); |
| | + } elseif( $type === 7 ) { |
| | + $sha = bin2hex( fread( $handle, 20 ) ); |
| | + $bas = $readShaBaseFn( $sha, $cap ); |
| | + $del = $this->inflate( $handle ); |
| | + $result = $this->decoder->apply( $bas, $del, $cap ); |
| | + } else { |
| | + $result = $this->inflate( $handle, $cap ); |
| | + } |
| | + |
| | + return $result; |
| | } |
| | |