Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/*
3
 *  $Id: BufferedWriter.php 227 2007-08-28 02:17:00Z hans $
4
 *
5
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
6
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
7
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
8
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
9
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
10
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
11
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
12
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
13
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
14
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
15
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16
 *
17
 * This software consists of voluntary contributions made by many individuals
18
 * and is licensed under the LGPL. For more information please see
19
 * <http://phing.info>.
20
 */
21
 
22
include_once 'phing/system/io/Writer.php';
23
 
24
/**
25
 * Convenience class for writing files.
26
 *
27
 * @author    Hans Lellelid <hans@xmpl.org>
28
 * @version   $Revision: 1.10 $
29
 * @package   phing.system.io
30
 */
31
class BufferedWriter extends Writer {
32
 
33
    /**
34
     * The size of the buffer in kb.
35
     */
36
    private $bufferSize    = 0;
37
 
38
    /**
39
     * @var Writer The Writer we are buffering output to.
40
     */
41
    private $out;
42
 
43
    public function __construct(Writer $writer, $buffsize = 8192) {
44
        $this->out = $writer;
45
        $this->bufferSize = $buffsize;
46
    }
47
 
48
    public function write($buf, $off = null, $len = null) {
49
        return $this->out->write($buf, $off, $len);
50
    }
51
 
52
    public function newLine() {
53
        $this->write(PHP_EOL);
54
    }
55
 
56
    public function getResource() {
57
        return $this->out->getResource();
58
    }
59
 
60
    public function flush() {
61
    	$this->out->flush();
62
    }
63
 
64
    /**
65
     * Close attached stream.
66
     */
67
    public function close() {
68
        return $this->out->close();
69
    }
70
 
71
}