Ticket #92: phing-inconsistent-newlines.diff

File phing-inconsistent-newlines.diff, 114.0 kB (added by DougWarner <silfreed-phing@silfreed.net>, 2 years ago)

Reparing DOS-style newlines

  • phing/filters/util/IniFileTokenReader.php

    old new  
    4848    /** 
    4949     * Reads the next token from the INI file 
    5050     * 
    51      * @throws  IOException     On error 
     51     * @throws  IOException     On error 
    5252     * @return Token 
    5353     */ 
    5454    function readToken() { 
  • phing/listener/AnsiColorLogger.php

    old new  
    197197    } 
    198198 
    199199    /** 
    200      * @see DefaultLogger#printMessage 
    201      * @param string $message 
    202      * @param OutputStream $stream 
     200     * @see DefaultLogger#printMessage 
     201     * @param string $message 
     202     * @param OutputStream $stream 
    203203     * @param int $priority 
    204204     */ 
    205205    protected final function printMessage($message, OutputStream $stream, $priority) { 
     
    226226                case Project::MSG_DEBUG: 
    227227                    $message = $this->debugColor . $message . self::END_COLOR; 
    228228                    break; 
    229             } 
    230              
     229            } 
     230             
    231231            $stream->write($message . $this->lSep); 
    232232        } 
    233233    } 
  • phing/listener/DefaultLogger.php

    old new  
    6060     *  property <em>line.seperator</em>. 
    6161     *  @var string 
    6262     */ 
    63     protected $lSep; 
    64      
    65     /** 
    66      * @var OutputStream Stream to use for standard output. 
    67      */ 
    68     protected $out; 
    69      
    70     /** 
    71      * @var OutputStream Stream to use for error output. 
    72      */ 
     63    protected $lSep; 
     64     
     65    /** 
     66     * @var OutputStream Stream to use for standard output. 
     67     */ 
     68    protected $out; 
     69     
     70    /** 
     71     * @var OutputStream Stream to use for error output. 
     72     */ 
    7373    protected $err; 
    7474 
    7575    /** 
     
    9898     * 
    9999     *  The default message level for DefaultLogger is Project::MSG_ERR. 
    100100     * 
    101      * @param int $level The logging level for the logger. 
     101     * @param int $level The logging level for the logger. 
    102102     * @see BuildLogger#setMessageOutputLevel() 
    103103     */ 
    104104    public function setMessageOutputLevel($level) { 
    105105        $this->msgOutputLevel = (int) $level; 
    106     } 
    107      
    108     /** 
    109      * Sets the output stream. 
    110      * @param OutputStream $output 
    111      * @see BuildLogger#setOutputStream() 
    112      */ 
    113     public function setOutputStream(OutputStream $output) { 
    114         $this->out = $output; 
    115     } 
    116          
    117     /** 
    118      * Sets the error stream. 
    119      * @param OutputStream $err 
    120      * @see BuildLogger#setErrorStream() 
    121      */ 
    122     public function setErrorStream(OutputStream $err) { 
    123         $this->err = $err; 
    124     } 
     106    } 
     107     
     108    /** 
     109     * Sets the output stream. 
     110     * @param OutputStream $output 
     111     * @see BuildLogger#setOutputStream() 
     112     */ 
     113    public function setOutputStream(OutputStream $output) { 
     114        $this->out = $output; 
     115    } 
     116         
     117    /** 
     118     * Sets the error stream. 
     119     * @param OutputStream $err 
     120     * @see BuildLogger#setErrorStream() 
     121     */ 
     122    public function setErrorStream(OutputStream $err) { 
     123        $this->err = $err; 
     124    } 
    125125     
    126126    /** 
    127127    *  Sets the start-time when the build started. Used for calculating 
     
    156156                $msg .= $error->getMessage(); 
    157157            } 
    158158        } 
    159         $msg .= $this->lSep . "Total time: " .self::formatTime(Phing::currentTimeMillis() - $this->startTime) . $this->lSep; 
    160          
    161         if ($error === null) { 
    162             $this->printMessage($msg, $this->out, Project::MSG_VERBOSE); 
    163         } else { 
    164             $this->printMessage($msg, $this->err, Project::MSG_ERR); 
    165         } 
    166     } 
    167  
    168         /** 
    169      * Get the message to return when a build failed. 
    170      * @return string The classic "BUILD FAILED" 
    171      */ 
    172     protected function getBuildFailedMessage() { 
    173         return "BUILD FAILED"; 
    174     } 
    175  
    176     /** 
    177      * Get the message to return when a build succeeded. 
    178      * @return string The classic "BUILD FINISHED" 
    179      */ 
    180     protected function getBuildSuccessfulMessage() { 
    181         return "BUILD FINISHED"; 
    182     } 
     159        $msg .= $this->lSep . "Total time: " .self::formatTime(Phing::currentTimeMillis() - $this->startTime) . $this->lSep; 
     160         
     161        if ($error === null) { 
     162            $this->printMessage($msg, $this->out, Project::MSG_VERBOSE); 
     163        } else { 
     164            $this->printMessage($msg, $this->err, Project::MSG_ERR); 
     165        } 
     166    } 
     167 
     168        /** 
     169     * Get the message to return when a build failed. 
     170     * @return string The classic "BUILD FAILED" 
     171     */ 
     172    protected function getBuildFailedMessage() { 
     173        return "BUILD FAILED"; 
     174    } 
     175 
     176    /** 
     177     * Get the message to return when a build succeeded. 
     178     * @return string The classic "BUILD FINISHED" 
     179     */ 
     180    protected function getBuildSuccessfulMessage() { 
     181        return "BUILD FINISHED"; 
     182    } 
    183183     
    184184    /** 
    185185     *  Prints the current target name 
     
    189189     *  @see    BuildEvent::getTarget() 
    190190     */ 
    191191    public function targetStarted(BuildEvent $event) { 
    192         if (Project::MSG_INFO <= $this->msgOutputLevel) { 
    193                 $msg = $this->lSep . $event->getProject()->getName() . ' > ' . $event->getTarget()->getName() . ':' . $this->lSep; 
     192        if (Project::MSG_INFO <= $this->msgOutputLevel) { 
     193                $msg = $this->lSep . $event->getProject()->getName() . ' > ' . $event->getTarget()->getName() . ':' . $this->lSep; 
    194194                $this->printMessage($msg, $this->out, $event->getPriority()); 
    195195        } 
    196196    } 
     
    231231     *  @access public 
    232232     *  @see    BuildEvent::getMessage() 
    233233     */ 
    234     public function messageLogged(BuildEvent $event) { 
     234    public function messageLogged(BuildEvent $event) { 
    235235        $priority = $event->getPriority(); 
    236236        if ($priority <= $this->msgOutputLevel) { 
    237237            $msg = ""; 
     
    239239                $name = $event->getTask(); 
    240240                $name = $name->getTaskName(); 
    241241                $msg = str_pad("[$name] ", self::LEFT_COLUMN_SIZE, " ", STR_PAD_LEFT); 
    242             } 
     242            } 
     243             
     244            $msg .= $event->getMessage(); 
    243245             
    244             $msg .= $event->getMessage(); 
    245              
    246             if ($priority != Project::MSG_ERR) { 
    247                 $this->printMessage($msg, $this->out, $priority); 
    248             } else { 
    249                 $this->printMessage($msg, $this->err, $priority); 
     246            if ($priority != Project::MSG_ERR) { 
     247                $this->printMessage($msg, $this->out, $priority); 
     248            } else { 
     249                $this->printMessage($msg, $this->err, $priority); 
    250250            } 
    251251        } 
    252252    } 
     
    273273     * Prints a message to console. 
    274274     *  
    275275     * @param string $message  The message to print.  
    276      *                 Should not be <code>null</code>. 
     276     *                 Should not be <code>null</code>. 
    277277     * @param resource $stream The stream to use for message printing. 
    278278     * @param int $priority The priority of the message.  
    279279     *                 (Ignored in this implementation.) 
    280280     * @return void 
    281281     */ 
    282     protected function printMessage($message, OutputStream $stream, $priority) { 
     282    protected function printMessage($message, OutputStream $stream, $priority) { 
    283283        $stream->write($message . $this->lSep); 
    284284    }     
    285285} 
  • phing/listener/NoBannerLogger.php

    old new  
    4242                $this->targetName = null; 
    4343        } 
    4444 
    45         function messageLogged(BuildEvent $event) { 
     45        function messageLogged(BuildEvent $event) { 
    4646                 
    4747                if ($event->getPriority() > $this->msgOutputLevel || null === $event->getMessage() || trim($event->getMessage() === "")) { 
    4848                        return; 
    49                 } 
     49                } 
    5050                 
    51                 if ($this->targetName !== null) { 
    52                         $msg = $this->lSep . $event->getProject()->getName() . ' > ' . $this->targetName . ':' . $this->lSep; 
     51                if ($this->targetName !== null) { 
     52                        $msg = $this->lSep . $event->getProject()->getName() . ' > ' . $this->targetName . ':' . $this->lSep; 
    5353                        $this->printMessage($msg, $this->out, $event->getPriority()); 
    5454                        $this->targetName = null; 
    5555                } 
  • phing/listener/PearLogListener.php

    old new  
    1919 * <http://phing.info>. 
    2020 */ 
    2121  
    22 require_once 'phing/BuildListener.php'; 
     22require_once 'phing/BuildListener.php'; 
    2323 
    2424/** 
    2525 * Writes build messages to PEAR Log. 
     
    6868     * Whether logging has been configured. 
    6969     * @var boolean 
    7070     */ 
    71     protected $logConfigured = false; 
    72      
    73     /** 
    74      * @var Log PEAR Log object. 
    75      */ 
    76         protected $logger; 
     71    protected $logConfigured = false; 
     72     
     73    /** 
     74     * @var Log PEAR Log object. 
     75     */ 
     76        protected $logger; 
    7777         
    7878    /** 
    7979     * Configure the logger. 
     
    8989        if ($name === null) $name = 'phing.log'; 
    9090        if ($ident === null) $ident = 'phing'; 
    9191        if ($conf === null) $conf = array(); 
    92          
    93         include_once 'Log.php'; 
    94         if (!class_exists('Log')) { 
    95                 throw new BuildException("Cannot find PEAR Log class for use by PearLogger."); 
    96         } 
     92         
     93        include_once 'Log.php'; 
     94        if (!class_exists('Log')) { 
     95                throw new BuildException("Cannot find PEAR Log class for use by PearLogger."); 
     96        } 
    9797         
    9898        $this->logger = Log::singleton($type, $name, $ident, $conf, self::$levelMap[$this->msgOutputLevel]); 
    9999    }         
  • phing/listener/XmlLogger.php

    old new  
    2121 
    2222require_once 'phing/BuildLogger.php'; 
    2323require_once 'phing/listener/DefaultLogger.php'; 
    24 require_once 'phing/system/util/Timer.php'; 
     24require_once 'phing/system/util/Timer.php'; 
    2525 
    2626/** 
    2727 * Generates a file in the current directory with 
     
    3333 * @version $Id: XmlLogger.php 147 2007-02-06 20:32:22Z hans $ 
    3434 * @package phing.listener 
    3535 */      
    36 class XmlLogger implements BuildLogger { 
     36class XmlLogger implements BuildLogger { 
    3737         
    3838        /** XML element name for a build. */ 
    3939        const BUILD_TAG = "build"; 
     
    5555        const ERROR_ATTR = "error"; 
    5656        /** XML element name for a stack trace. */ 
    5757        const STACKTRACE_TAG = "stacktrace"; 
    58          
    59         /** 
    60          * @var DOMDocument The XML document created by this logger.  
     58         
     59        /** 
     60         * @var DOMDocument The XML document created by this logger.  
    6161         */ 
    6262        private $doc; 
    6363         
     
    6666        private $taskStartTime = 0; 
    6767         
    6868        private $buildElement; 
    69          
    70         /** 
    71          * @var int 
     69         
     70        /** 
     71         * @var int 
    7272         */ 
    7373        private $msgOutputLevel = Project::MSG_DEBUG; 
    74          
    75         /** 
    76      * @var OutputStream Stream to use for standard output. 
    77      */ 
    78         private $out; 
    79     
    80         /** 
    81          * @var OutputStream Stream to use for error output. 
    82          */ 
    83         private $err; 
     74         
     75        /** 
     76     * @var OutputStream Stream to use for standard output. 
     77     */ 
     78        private $out; 
     79    
     80        /** 
     81         * @var OutputStream Stream to use for error output. 
     82         */ 
     83        private $err; 
    8484         
    8585        /** 
    8686         * @var string Name of filename to create. 
     
    117117         * @param BuildEvent $event An event with any relevant extra information. 
    118118         *              Will not be <code>null</code>. 
    119119         */ 
    120         public function buildFinished(BuildEvent $event) { 
     120        public function buildFinished(BuildEvent $event) { 
    121121                 
    122122                $this->buildTimer->stop(); 
    123123                 
     
    134134                        $stacktrace->appendChild($errText); 
    135135                        $this->buildElement->appendChild($stacktrace); 
    136136                } 
    137                  
    138                 $this->doc->appendChild($this->buildElement); 
    139                  
    140                 $outFilename = $event->getProject()->getProperty("XmlLogger.file"); 
    141         if ($outFilename == null) { 
    142             $outFilename = "log.xml"; 
    143         } 
    144          
    145         try { 
    146                 $stream = $this->out; 
    147                 if ($stream === null) { 
    148                         $stream = new FileOutputStream($outFilename);  
    149                 } 
    150                  
    151                 // Yes, we could just stream->write() but this will eventually be the better 
    152                         // way to do this (when we need to worry about charset conversions.  
    153                 $writer = new OutputStreamWriter($stream); 
    154                 $writer->write($this->doc->saveXML()); 
    155                 $writer->close(); 
    156         } catch (IOException $exc) { 
    157                 try { 
    158                         $stream->close(); // in case there is a stream open still ... 
    159                 } catch (Exception $x) {} 
    160                 throw new BuildException("Unable to write log file.", $exc); 
    161         } 
    162         } 
    163          
     137                 
     138                $this->doc->appendChild($this->buildElement); 
     139                 
     140                $outFilename = $event->getProject()->getProperty("XmlLogger.file"); 
     141        if ($outFilename == null) { 
     142            $outFilename = "log.xml"; 
     143        } 
     144         
     145        try { 
     146                $stream = $this->out; 
     147                if ($stream === null) { 
     148                        $stream = new FileOutputStream($outFilename);  
     149                } 
     150                 
     151                // Yes, we could just stream->write() but this will eventually be the better 
     152                        // way to do this (when we need to worry about charset conversions.  
     153                $writer = new OutputStreamWriter($stream); 
     154                $writer->write($this->doc->saveXML()); 
     155                $writer->close(); 
     156        } catch (IOException $exc) { 
     157                try { 
     158                        $stream->close(); // in case there is a stream open still ... 
     159                } catch (Exception $x) {} 
     160                throw new BuildException("Unable to write log file.", $exc); 
     161        } 
     162        } 
     163         
    164164         
    165165        /** 
    166166         * Fired when a target starts building, remembers the current time and the name of the target. 
     
    188188                $target = $event->getTarget(); 
    189189                $elapsedTime = Phing::currentTimeMillis() - $this->targetTimerStart; 
    190190                $this->targetElement->setAttribute(XmlLogger::TIME_ATTR, DefaultLogger::formatTime($elapsedTime)); 
    191                 $this->buildElement->appendChild($this->targetElement); 
     191                $this->buildElement->appendChild($this->targetElement); 
    192192                $this->targetElement = null; 
    193193        } 
    194194         
     
    204204                $this->taskElement = $this->doc->createElement(XmlLogger::TASK_TAG); 
    205205                $this->taskElement->setAttribute(XmlLogger::NAME_ATTR, $task->getTaskName()); 
    206206                $this->taskElement->setAttribute(XmlLogger::LOCATION_ATTR, $task->getLocation()->toString()); 
    207         } 
     207        } 
    208208         
    209209        /** 
    210210         * Fired when a task finishes building, this adds the time taken 
     
    217217                $task = $event->getTask(); 
    218218                $elapsedTime = Phing::currentTimeMillis() - $this->taskTimerStart; 
    219219                $this->taskElement->setAttribute(XmlLogger::TIME_ATTR, DefaultLogger::formatTime($elapsedTime)); 
    220                 if ($this->targetElement) { // not all tasks are in targets 
    221                         $this->targetElement->appendChild($this->taskElement); 
    222                 } else { 
    223                         $this->buildElement->appendChild($this->taskElement); 
    224                 } 
     220                if ($this->targetElement) { // not all tasks are in targets 
     221                        $this->targetElement->appendChild($this->taskElement); 
     222                } else { 
     223                        $this->buildElement->appendChild($this->taskElement); 
     224                } 
    225225                $this->taskElement = null; 
    226226        } 
    227227         
     
    272272                        $this->buildElement->appendChild($messageElement); 
    273273                } 
    274274        } 
    275  
    276     /** 
    277      *  Set the msgOutputLevel this logger is to respond to. 
    278      * 
    279      *  Only messages with a message level lower than or equal to the given 
    280      *  level are output to the log. 
    281      * 
    282      *  <p> Constants for the message levels are in Project.php. The order of 
    283      *  the levels, from least to most verbose, is: 
    284      * 
    285      *  <ul> 
    286      *    <li>Project::MSG_ERR</li> 
    287      *    <li>Project::MSG_WARN</li> 
    288      *    <li>Project::MSG_INFO</li> 
    289      *    <li>Project::MSG_VERBOSE</li> 
    290      *    <li>Project::MSG_DEBUG</li> 
    291      *  </ul> 
    292      * 
    293      *  The default message level for DefaultLogger is Project::MSG_ERR. 
    294      * 
    295      * @param int $level The logging level for the logger. 
    296      * @see BuildLogger#setMessageOutputLevel() 
    297      */ 
    298     public function setMessageOutputLevel($level) { 
    299         $this->msgOutputLevel = (int) $level; 
    300     } 
    301      
    302     /** 
    303      * Sets the output stream. 
    304      * @param OutputStream $output 
    305      * @see BuildLogger#setOutputStream() 
    306      */ 
    307     public function setOutputStream(OutputStream $output) { 
    308         $this->out = $output; 
    309     } 
    310          
    311     /** 
    312      * Sets the error stream. 
    313      * @param OutputStream $err 
    314      * @see BuildLogger#setErrorStream() 
    315      */ 
    316     public function setErrorStream(OutputStream $err) { 
    317         $this->err = $err; 
    318     } 
     275 
     276    /** 
     277     *  Set the msgOutputLevel this logger is to respond to. 
     278     * 
     279     *  Only messages with a message level lower than or equal to the given 
     280     *  level are output to the log. 
     281     * 
     282     *  <p> Constants for the message levels are in Project.php. The order of 
     283     *  the levels, from least to most verbose, is: 
     284     * 
     285     *  <ul> 
     286     *    <li>Project::MSG_ERR</li> 
     287     *    <li>Project::MSG_WARN</li> 
     288     *    <li>Project::MSG_INFO</li> 
     289     *    <li>Project::MSG_VERBOSE</li> 
     290     *    <li>Project::MSG_DEBUG</li> 
     291     *  </ul> 
     292     * 
     293     *  The default message level for DefaultLogger is Project::MSG_ERR. 
     294     * 
     295     * @param int $level The logging level for the logger. 
     296     * @see BuildLogger#setMessageOutputLevel() 
     297     */ 
     298    public function setMessageOutputLevel($level) { 
     299        $this->msgOutputLevel = (int) $level; 
     300    } 
     301     
     302    /** 
     303     * Sets the output stream. 
     304     * @param OutputStream $output 
     305     * @see BuildLogger#setOutputStream() 
     306     */ 
     307    public function setOutputStream(OutputStream $output) { 
     308        $this->out = $output; 
     309    } 
     310         
     311    /** 
     312     * Sets the error stream. 
     313     * @param OutputStream $err 
     314     * @see BuildLogger#setErrorStream() 
     315     */ 
     316    public function setErrorStream(OutputStream $err) { 
     317        $this->err = $err; 
     318    } 
    319319         
    320320} 
  • phing/system/io/BufferedReader.php

    old new  
    5353    } 
    5454 
    5555    /** 
    56      * Reads and returns a chunk of data. 
     56     * Reads and returns a chunk of data. 
    5757     * @param int $len Number of bytes to read.  Default is to read configured buffer size number of bytes. 
    5858     * @return mixed buffer or -1 if EOF. 
    5959     */ 
    6060    function read($len = null) { 
    61          
    62         // if $len is specified, we'll use that; otherwise, use the configured buffer size. 
     61         
     62        // if $len is specified, we'll use that; otherwise, use the configured buffer size. 
    6363        if ($len === null) $len = $this->bufferSize;  
    6464         
    6565        if ( ($data = $this->in->read($len)) !== -1 ) { 
  • phing/system/io/BufferedWriter.php

    old new  
    5555     
    5656    public function getResource() { 
    5757        return $this->out->getResource(); 
    58     } 
    59      
    60     public function flush() { 
    61         $this->out->flush(); 
    6258    } 
    63          
    64     /** 
    65      * Close attached stream. 
     59     
     60    public function flush() { 
     61        $this->out->flush(); 
     62    } 
     63         
     64    /** 
     65     * Close attached stream. 
    6666     */ 
    6767    public function close() { 
    6868        return $this->out->close(); 
  • phing/system/io/FileInputStream.php

    old new  
    1818 * and is licensed under the LGPL. For more information please see 
    1919 * <http://phing.info>. 
    2020 */ 
    21  
    22 require_once 'phing/system/io/InputStream.php'; 
    23 require_once 'phing/system/io/PhingFile.php'; 
     21 
     22require_once 'phing/system/io/InputStream.php'; 
     23require_once 'phing/system/io/PhingFile.php'; 
    2424 
    2525/** 
    26  * Input stream subclass for file streams. 
     26 * Input stream subclass for file streams. 
    2727 *  
    2828 * @package   phing.system.io 
    2929 */ 
    3030class FileInputStream extends InputStream { 
    31          
    32         /** 
    33          * @var PhingFile The associated file. 
    34          */ 
    35         protected $file; 
     31         
     32        /** 
     33         * @var PhingFile The associated file. 
     34         */ 
     35        protected $file; 
    3636         
    3737    /** 
    3838     * Construct a new FileInputStream. 
    39      * @param mixed $file 
    40      * @throws Exception - if invalid argument specified. 
     39     * @param mixed $file 
     40     * @throws Exception - if invalid argument specified. 
    4141     * @throws IOException - if unable to open file. 
    4242     */ 
    43     public function __construct($file, $append = false) { 
    44         if ($file instanceof PhingFile) { 
    45             $this->file = $file; 
    46         } elseif (is_string($file)) { 
    47             $this->file = new PhingFile($file); 
    48         } else { 
    49             throw new Exception("Invalid argument type for \$file."); 
    50         } 
    51          
    52         $stream = @fopen($this->file->getAbsolutePath(), "rb"); 
    53         if ($stream === false) { 
    54                 throw new IOException("Unable to open " . $this->file->__toString() . " for reading: " . $php_errormsg); 
    55         } 
    56          
     43    public function __construct($file, $append = false) { 
     44        if ($file instanceof PhingFile) { 
     45            $this->file = $file; 
     46        } elseif (is_string($file)) { 
     47            $this->file = new PhingFile($file); 
     48        } else { 
     49            throw new Exception("Invalid argument type for \$file."); 
     50        } 
     51         
     52        $stream = @fopen($this->file->getAbsolutePath(), "rb"); 
     53        if ($stream === false) { 
     54                throw new IOException("Unable to open " . $this->file->__toString() . " for reading: " . $php_errormsg); 
     55        } 
     56         
    5757        parent::__construct($stream); 
    5858    } 
    59      
    60     /** 
    61      * Returns a string representation of the attached file. 
    62      * @return string 
     59     
     60    /** 
     61     * Returns a string representation of the attached file. 
     62     * @return string 
    6363     */ 
    6464    public function __toString() { 
    6565        return $this->file->getPath(); 
    66     } 
    67      
    68     /** 
    69      * Mark is supported by FileInputStream. 
    70      * @return boolean TRUE 
    71      */ 
    72         public function markSupported() { 
    73         return true; 
     66    } 
     67     
     68    /** 
     69     * Mark is supported by FileInputStream. 
     70     * @return boolean TRUE 
     71     */ 
     72        public function markSupported() { 
     73        return true; 
    7474    } 
    7575} 
    7676 
  • phing/system/io/FileOutputStream.php

    old new  
    1818 * and is licensed under the LGPL. For more information please see 
    1919 * <http://phing.info>. 
    2020 */ 
    21  
    22 require_once 'phing/system/io/OutputStream.php'; 
    23 require_once 'phing/system/io/PhingFile.php'; 
     21 
     22require_once 'phing/system/io/OutputStream.php'; 
     23require_once 'phing/system/io/PhingFile.php'; 
    2424 
    2525/** 
    26  * Output stream subclass for file streams. 
     26 * Output stream subclass for file streams. 
    2727 *  
    2828 * @package   phing.system.io 
    2929 */ 
    3030class FileOutputStream extends OutputStream { 
    31          
    32         /** 
    33          * @var PhingFile The associated file. 
    34          */ 
    35         protected $file; 
     31         
     32        /** 
     33         * @var PhingFile The associated file. 
     34         */ 
     35        protected $file; 
    3636         
    3737    /** 
    3838     * Construct a new FileOutputStream. 
    39      * @param mixed $file 
    40      * @param boolean $append Whether to append bytes to end of file rather than beginning. 
    41      * @throws Exception - if invalid argument specified. 
     39     * @param mixed $file 
     40     * @param boolean $append Whether to append bytes to end of file rather than beginning. 
     41     * @throws Exception - if invalid argument specified. 
    4242     * @throws IOException - if unable to open file. 
    4343     */ 
    44     public function __construct($file, $append = false) { 
    45         if ($file instanceof PhingFile) { 
    46             $this->file = $file; 
    47         } elseif (is_string($file)) { 
    48             $this->file = new PhingFile($file); 
    49         } else { 
    50             throw new Exception("Invalid argument type for \$file."); 
    51         } 
    52         if ($append) { 
    53                 $stream = @fopen($this->file->getAbsolutePath(), "ab"); 
    54         } else { 
    55                 $stream = @fopen($this->file->getAbsolutePath(), "wb"); 
    56         } 
    57         if ($stream === false) { 
    58                 throw new IOException("Unable to open " . $this->file->__toString() . " for writing: " . $php_errormsg); 
    59         } 
     44    public function __construct($file, $append = false) { 
     45        if ($file instanceof PhingFile) { 
     46            $this->file = $file; 
     47        } elseif (is_string($file)) { 
     48            $this->file = new PhingFile($file); 
     49        } else { 
     50            throw new Exception("Invalid argument type for \$file."); 
     51        } 
     52        if ($append) { 
     53                $stream = @fopen($this->file->getAbsolutePath(), "ab"); 
     54        } else { 
     55                $stream = @fopen($this->file->getAbsolutePath(), "wb"); 
     56        } 
     57        if ($stream === false) { 
     58                throw new IOException("Unable to open " . $this->file->__toString() . " for writing: " . $php_errormsg); 
     59        } 
    6060        parent::__construct($stream); 
    6161    } 
    62      
    63     /** 
    64      * Returns a string representation of the attached file. 
    65      * @return string 
     62     
     63    /** 
     64     * Returns a string representation of the attached file. 
     65     * @return string 
    6666     */ 
    6767    public function __toString() { 
    6868        return $this->file->getPath(); 
  • phing/system/io/FileReader.php

    old new  
    2020 */ 
    2121 
    2222require_once 'phing/system/io/InputStreamReader.php'; 
    23 require_once 'phing/system/io/FileInputStream.php'; 
     23require_once 'phing/system/io/FileInputStream.php'; 
    2424 
    2525/** 
    2626 * Convenience class for reading files. 
     
    2828 */ 
    2929class FileReader extends InputStreamReader { 
    3030 
    31         /** 
    32      * Construct a new FileReader. 
    33      * @param mixed $file PhingFile or string pathname. 
    34      */ 
    35     public function __construct($file) { 
    36         $in = new FileInputStream($file); 
    37         parent::__construct($in); 
    38     } 
    39          
     31        /** 
     32     * Construct a new FileReader. 
     33     * @param mixed $file PhingFile or string pathname. 
     34     */ 
     35    public function __construct($file) { 
     36        $in = new FileInputStream($file); 
     37        parent::__construct($in); 
     38    } 
     39         
    4040} 
    4141 
  • phing/system/io/FileSystem.php

    old new  
    5151     
    5252    /** 
    5353     * Static method to return the FileSystem singelton representing 
    54      * this platform's local filesystem driver. 
     54     * this platform's local filesystem driver. 
    5555     * @return FileSystem 
    5656     */ 
    5757    public static function getFileSystem() { 
  • phing/system/io/FileWriter.php

    old new  
    2020 */ 
    2121 
    2222require_once 'phing/system/io/OutputStreamWriter.php'; 
    23 require_once 'phing/system/io/FileOutputStream.php'; 
     23require_once 'phing/system/io/FileOutputStream.php'; 
    2424 
    2525/** 
    2626 * Convenience class for performing file write operations. 
     
    3434     * @param mixed $file PhingFile or string pathname. 
    3535     * @param boolean $append Append to existing file? 
    3636     */ 
    37     function __construct($file, $append = false) { 
    38         $out = new FileOutputStream($file, $append); 
     37    function __construct($file, $append = false) { 
     38        $out = new FileOutputStream($file, $append); 
    3939        parent::__construct($out); 
    4040    } 
    4141} 
  • phing/system/io/FilterReader.php

    old new  
    2626 * @package phing.system.io 
    2727 */ 
    2828class FilterReader extends Reader { 
    29      
    30         /**  
    31          * @var Reader 
     29     
     30        /**  
     31         * @var Reader 
    3232         */ 
    3333    protected $in; 
    3434     
     
    5959     
    6060    public function close() { 
    6161        return $this->in->close(); 
    62     } 
     62    } 
    6363     
    6464    function getResource() { 
    6565        return $this->in->getResource(); 
  • phing/system/io/InputStream.php

    old new  
    2020 */ 
    2121 
    2222/** 
    23  * Wrapper class for PHP stream that supports read operations. 
     23 * Wrapper class for PHP stream that supports read operations. 
    2424 *  
    2525 * @package   phing.system.io 
    2626 */ 
    2727class InputStream { 
    28          
    29         /** 
    30          * @var resource The attached PHP stream. 
    31          */ 
    32         protected $stream; 
    33          
    34         /** 
    35          * @var int Position of stream cursor. 
     28         
     29        /** 
     30         * @var resource The attached PHP stream. 
    3631         */ 
    37     protected $currentPosition = 0; 
    38      
    39     /** 
    40      * @var int Marked position of stream cursor. 
     32        protected $stream; 
     33         
     34        /** 
     35         * @var int Position of stream cursor. 
     36         */ 
     37    protected $currentPosition = 0; 
     38     
     39    /** 
     40     * @var int Marked position of stream cursor. 
    4141     */ 
    4242    protected $mark = 0; 
    43          
    44         /** 
    45      * Construct a new InputStream. 
    46      * @param resource $stream Configured PHP stream for writing. 
    47      */ 
    48     public function __construct($stream) { 
    49         if (!is_resource($stream)) { 
    50                 throw new IOException("Passed argument is not a valid stream."); 
    51         } 
    52         $this->stream = $stream; 
    53     } 
    54  
    55     /** 
    56      * Skip over $n bytes. 
    57      * @param int $n 
     43         
     44        /** 
     45     * Construct a new InputStream. 
     46     * @param resource $stream Configured PHP stream for writing. 
     47     */ 
     48    public function __construct($stream) { 
     49        if (!is_resource($stream)) { 
     50                throw new IOException("Passed argument is not a valid stream."); 
     51        } 
     52        $this->stream = $stream; 
     53    } 
     54 
     55    /** 
     56     * Skip over $n bytes. 
     57     * @param int $n 
    5858     */ 
    5959    public function skip($n) { 
    6060        $start = $this->currentPosition; 
     
    7878     * @param int $len Num chars to read.  If not specified this stream will read until EOF. 
    7979     * @return string chars read or -1 if eof. 
    8080     */ 
    81     public function read($len = null) { 
     81    public function read($len = null) { 
    8282         
    8383        if ($this->eof()) { 
    8484            return -1; 
    85         } 
    86          
    87         if ($len === null) { // we want to keep reading until we get an eof 
    88                         $out = ""; 
    89                 while(!$this->eof()) { 
    90                         $out .= fread($this->stream, 8192); 
    91                         $this->currentPosition = ftell($this->stream); 
    92                 } 
    93         } else { 
    94                         $out = fread($this->stream, $len); // adding 1 seems to ensure that next call to read() will return EOF (-1) 
    95                 $this->currentPosition = ftell($this->stream); 
     85        } 
     86         
     87        if ($len === null) { // we want to keep reading until we get an eof 
     88                        $out = ""; 
     89                while(!$this->eof()) { 
     90                        $out .= fread($this->stream, 8192); 
     91                        $this->currentPosition = ftell($this->stream); 
     92                } 
     93        } else { 
     94                        $out = fread($this->stream, $len); // adding 1 seems to ensure that next call to read() will return EOF (-1) 
     95                $this->currentPosition = ftell($this->stream); 
    9696        } 
    9797 
    9898        return $out; 
    9999    }     
    100      
    101     /** 
    102      * Marks the current position in this input stream. 
    103      * @throws IOException - if the underlying stream doesn't support this method. 
    104      */ 
    105     public function mark() { 
    106         if (!$this->markSupported()) { 
    107                 throw new IOException(get_class($this) . " does not support mark() and reset() methods."); 
     100     
     101    /** 
     102     * Marks the current position in this input stream. 
     103     * @throws IOException - if the underlying stream doesn't support this method. 
     104     */ 
     105    public function mark() { 
     106        if (!$this->markSupported()) { 
     107                throw new IOException(get_class($this) . " does not support mark() and reset() methods."); 
    108108        } 
    109109        $this->mark = $this->currentPosition; 
    110     } 
    111      
    112     /** 
    113      * Whether the input stream supports mark and reset methods. 
    114      * @return boolean 
    115      */ 
    116     public function markSupported() { 
    117         return false; 
    118     } 
    119      
    120     /** 
    121      * Repositions this stream to the position at the time the mark method was last called on this input stream. 
    122      * @throws IOException - if the underlying stream doesn't support this method. 
    123