3 final class PhabricatorFileChunkIterator
13 public function __construct(array $chunks, $begin = null, $end = null) {
14 $chunks = msort($chunks, 'getByteStart');
15 $this->chunks
= $chunks;
17 if ($begin !== null) {
18 foreach ($chunks as $key => $chunk) {
19 if ($chunk->getByteEnd() >= $begin) {
24 $this->begin
= $begin;
28 foreach ($chunks as $key => $chunk) {
29 if ($chunk->getByteStart() <= $end) {
37 public function current() {
38 $chunk = head($this->chunks
);
39 $data = $chunk->getDataFile()->loadFileData();
41 if ($this->end
!== null) {
42 if ($chunk->getByteEnd() > $this->end
) {
43 $data = substr($data, 0, ($this->end
- $chunk->getByteStart()));
47 if ($this->begin
!== null) {
48 if ($chunk->getByteStart() < $this->begin
) {
49 $data = substr($data, ($this->begin
- $chunk->getByteStart()));
56 public function key() {
57 return head_key($this->chunks
);
60 public function next() {
61 unset($this->chunks
[$this->key()]);
64 public function rewind() {
68 public function valid() {
69 return (count($this->chunks
) > 0);