WEB_ARCHIVE_VERSION
WEB_ARCHIVE_VERSION
Version number to use in the WebArchive header if constructing a new archive
Code used to manage web archive files
__construct(string $fname, string $compressor, boolean $fast_construct = false, boolean $is_string = false)
Makes or initializes a WebArchive object using the supplied parameters
string | $fname | filename to use to store archive to disk |
string | $compressor | what kind of Compressor object should be used to read and write objects in the archive |
boolean | $fast_construct | do we read the info block of the web archive as part of the constructing process |
boolean | $is_string | says whether the archive stores to string rather than a file |
writeInfoBlock(resource $fh = null, \seekquarry\yioop\library\array& $data = null)
Serializes and applies the compressor to an info block and write it at the end of the web archive The info block is meta data for the archive stored at the end of the WebArchive file. The particular meta is up to who is using the web archive; however, count and archive version number are always stored
resource | $fh | resource for the web archive file. If null the web archive is open first and close when the data is written |
\seekquarry\yioop\library\array& | $data | data to write into the info block of the archive |
seekEndObjects(resource $fh) : integer
Seeks in the WebArchive file to the end of the last Object.
The last $compressed_int_len bytes of a WebArchive say the length of an info block in bytes
resource | $fh | resource for the WebArchive file |
offset length of info block
addObjects(string $offset_field, \seekquarry\yioop\library\array& $objects, array $data = null, string $callback = null, boolean $return_flag = true) : mixed
Adds objects to the WebArchive
string | $offset_field | field in objects to return the byte offset at which they were stored |
\seekquarry\yioop\library\array& | $objects | references to objects that will be stored the offset field in these references will be adjusted if |
array | $data | data to write in the WebArchive's info block |
string | $callback | name of a callback $callback($data, $new_objects, $offset_field) used to modify $data before it is written to the info block. For instance, we can add offset info to data. |
boolean | $return_flag | if true rather than adjust the offsets by reference, create copy objects and adjust their offsets and return |
adjusted objects or void
getObjects(integer $offset, integer $num, boolean $next_flag = true, resource $fh = null, integer $max_size = \seekquarry\yioop\configs\MAX_ARCHIVE_OBJECT_SIZE) : array
Gets $num many objects out of the web archive starting at byte $offset
If the $next_flag is true the archive iterator is advance and if $fh is not null then it is assumed to be an open resource pointing to the archive (saving the time to open it).
integer | $offset | a valid byte offset into a web archive |
integer | $num | number of objects to return |
boolean | $next_flag | whether to advance the archive iterator |
resource | $fh | either null or a file resource to the archive |
integer | $max_size | maximum size returned object should be, use as a sanity check against corrupted archives |
the $num objects beginning at $offset
nextObjects(integer $num) : array
Returns $num many objects from the web archive starting at the current iterator position. The iterator is advance to the object after the last one returned
integer | $num | number of objects to return |
an array of objects from the web archive