Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F121769028
PhabricatorFileChunkIterator.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Jul 13, 18:08
Size
1 KB
Mime Type
text/x-php
Expires
Tue, Jul 15, 18:08 (2 d)
Engine
blob
Format
Raw Data
Handle
27366903
Attached To
rPH Phabricator
PhabricatorFileChunkIterator.php
View Options
<?php
final
class
PhabricatorFileChunkIterator
extends
Phobject
implements
Iterator
{
private
$chunks
;
private
$cursor
;
private
$begin
;
private
$end
;
private
$data
;
public
function
__construct
(
array
$chunks
,
$begin
=
null
,
$end
=
null
)
{
$chunks
=
msort
(
$chunks
,
'getByteStart'
);
$this
->
chunks
=
$chunks
;
if
(
$begin
!==
null
)
{
foreach
(
$chunks
as
$key
=>
$chunk
)
{
if
(
$chunk
->
getByteEnd
()
>=
$begin
)
{
unset
(
$chunks
[
$key
]);
}
break
;
}
$this
->
begin
=
$begin
;
}
if
(
$end
!==
null
)
{
foreach
(
$chunks
as
$key
=>
$chunk
)
{
if
(
$chunk
->
getByteStart
()
<=
$end
)
{
unset
(
$chunks
[
$key
]);
}
}
$this
->
end
=
$end
;
}
}
public
function
current
()
{
$chunk
=
head
(
$this
->
chunks
);
$data
=
$chunk
->
getDataFile
()->
loadFileData
();
if
(
$this
->
end
!==
null
)
{
if
(
$chunk
->
getByteEnd
()
>
$this
->
end
)
{
$data
=
substr
(
$data
,
0
,
(
$this
->
end
-
$chunk
->
getByteStart
()));
}
}
if
(
$this
->
begin
!==
null
)
{
if
(
$chunk
->
getByteStart
()
<
$this
->
begin
)
{
$data
=
substr
(
$data
,
(
$this
->
begin
-
$chunk
->
getByteStart
()));
}
}
return
$data
;
}
public
function
key
()
{
return
head_key
(
$this
->
chunks
);
}
public
function
next
()
{
unset
(
$this
->
chunks
[
$this
->
key
()]);
}
public
function
rewind
()
{
return
;
}
public
function
valid
()
{
return
(
count
(
$this
->
chunks
)
>
0
);
}
}
Event Timeline
Log In to Comment