Changeset 919

Show
Ignore:
Timestamp:
09/15/07 16:24:52 (1 year ago)
Author:
mikey
Message:

finished file handler for simpletest streamwrapper extension

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/org/simpletest/extensions/streamwrapper/file.php

    r918 r919  
    5353 
    5454    /** 
     55     * checks whether the container can be applied to given name 
     56     * 
     57     * @param   string  $name 
     58     * @return  bool 
     59     */ 
     60    public function appliesTo($name) 
     61    { 
     62        return ($name === $this->name); 
     63    } 
     64 
     65    /** 
    5566     * sets the contents of the file 
    5667     * 
     
    6071    { 
    6172        $this->content = $content; 
     73    } 
     74 
     75    /** 
     76     * returns the contents of the file 
     77     * 
     78     * @return  string 
     79     */ 
     80    public function getContent() 
     81    { 
     82        return $this->content; 
    6283    } 
    6384 
     
    7697 
    7798    /** 
     99     * returns the content until its end from current offset 
     100     * 
     101     * @return  string 
     102     */ 
     103    public function readUntilEnd() 
     104    { 
     105        return substr($this->content, $this->bytes_read); 
     106    } 
     107 
     108    /** 
    78109     * writes an amount of data 
    79110     * 
     
    83114    public function write($data) 
    84115    { 
    85         // write data to content 
    86         return 0; 
     116        $dataLen           = strlen($data); 
     117        $this->content     = substr($this->content, 0, $this->bytes_read) . $data . substr($this->content, $this->bytes_read + $dataLen); 
     118        $this->bytes_read += $dataLen; 
     119        return $dataLen; 
    87120    } 
    88121