/dev/trunk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/dev/trunk

« back to all changes in this revision

Viewing changes to classes/stream/streamreader.php

  • Committer: Suren A. Chilingaryan
  • Date: 2008-04-02 10:23:22 UTC
  • Revision ID: csa@dside.dyndns.org-20080402102322-okib92sicg2dx3o3
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
abstract class VIRTUALStreamReaderWriter extends VIRTUALStreamObject implements STREAMReaderInterface {
 
3
 var $output = false;
 
4
 
 
5
 function StreamData(STREAMWriterInterface $h = NULL, $flags = 0) {
 
6
    if ($this->output) $h = $this->output;
 
7
    else if (!$h) throw new ADEIException(translate("The data routing is failed (there is no output specified for STREAMReader)"));
 
8
    
 
9
    do {
 
10
        $data = $this->ReadData(STREAM::BUFFER_SIZE, $flags);
 
11
        if ($data) $h->WriteData($data, $flags);
 
12
    } while ($data);
 
13
 }
 
14
 
 
15
 function Stream(STREAMWriterInterface $h = NULL, $flags = 0) {
 
16
    if ($this->output) $h = $this->output;
 
17
    else if (!$h) throw new ADEIException(translate("The data routing is failed (there is no output specified for STREAMReader)"));
 
18
 
 
19
    while (!$this->EOS($flags)) {
 
20
        $data = $this->ReadData(STREAM::BUFFER_SIZE, $flags|STREAM::BLOCK);
 
21
        if ($data) $h->WriteData($data, $flags);
 
22
    }
 
23
 }
 
24
 
 
25
 function GetContent($flags = 0) {
 
26
    $res = "";
 
27
    while (!$this->EOS($flags)) {
 
28
        $data = $this->ReadData(0, $flags|STREAM::BLOCK);
 
29
        if ($data) $res .= $data;
 
30
    }
 
31
    return $res;
 
32
 }
 
33
}
 
34
?>
 
 
b'\\ No newline at end of file'