Ticket #92: phing-inconsistent-newlines.diff
| File phing-inconsistent-newlines.diff, 114.0 kB (added by DougWarner <silfreed-phing@silfreed.net>, 2 years ago) |
|---|
-
phing/filters/util/IniFileTokenReader.php
old new 48 48 /** 49 49 * Reads the next token from the INI file 50 50 * 51 * @throws IOException On error 51 * @throws IOException On error 52 52 * @return Token 53 53 */ 54 54 function readToken() { -
phing/listener/AnsiColorLogger.php
old new 197 197 } 198 198 199 199 /** 200 * @see DefaultLogger#printMessage 201 * @param string $message 202 * @param OutputStream $stream 200 * @see DefaultLogger#printMessage 201 * @param string $message 202 * @param OutputStream $stream 203 203 * @param int $priority 204 204 */ 205 205 protected final function printMessage($message, OutputStream $stream, $priority) { … … 226 226 case Project::MSG_DEBUG: 227 227 $message = $this->debugColor . $message . self::END_COLOR; 228 228 break; 229 } 230 229 } 230 231 231 $stream->write($message . $this->lSep); 232 232 } 233 233 } -
phing/listener/DefaultLogger.php
old new 60 60 * property <em>line.seperator</em>. 61 61 * @var string 62 62 */ 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 */ 73 73 protected $err; 74 74 75 75 /** … … 98 98 * 99 99 * The default message level for DefaultLogger is Project::MSG_ERR. 100 100 * 101 * @param int $level The logging level for the logger. 101 * @param int $level The logging level for the logger. 102 102 * @see BuildLogger#setMessageOutputLevel() 103 103 */ 104 104 public function setMessageOutputLevel($level) { 105 105 $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 } 125 125 126 126 /** 127 127 * Sets the start-time when the build started. Used for calculating … … 156 156 $msg .= $error->getMessage(); 157 157 } 158 158 } 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 } 183 183 184 184 /** 185 185 * Prints the current target name … … 189 189 * @see BuildEvent::getTarget() 190 190 */ 191 191 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; 194 194 $this->printMessage($msg, $this->out, $event->getPriority()); 195 195 } 196 196 } … … 231 231 * @access public 232 232 * @see BuildEvent::getMessage() 233 233 */ 234 public function messageLogged(BuildEvent $event) { 234 public function messageLogged(BuildEvent $event) { 235 235 $priority = $event->getPriority(); 236 236 if ($priority <= $this->msgOutputLevel) { 237 237 $msg = ""; … … 239 239 $name = $event->getTask(); 240 240 $name = $name->getTaskName(); 241 241 $msg = str_pad("[$name] ", self::LEFT_COLUMN_SIZE, " ", STR_PAD_LEFT); 242 } 242 } 243 244 $msg .= $event->getMessage(); 243 245 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); 250 250 } 251 251 } 252 252 } … … 273 273 * Prints a message to console. 274 274 * 275 275 * @param string $message The message to print. 276 * Should not be <code>null</code>. 276 * Should not be <code>null</code>. 277 277 * @param resource $stream The stream to use for message printing. 278 278 * @param int $priority The priority of the message. 279 279 * (Ignored in this implementation.) 280 280 * @return void 281 281 */ 282 protected function printMessage($message, OutputStream $stream, $priority) { 282 protected function printMessage($message, OutputStream $stream, $priority) { 283 283 $stream->write($message . $this->lSep); 284 284 } 285 285 } -
phing/listener/NoBannerLogger.php
old new 42 42 $this->targetName = null; 43 43 } 44 44 45 function messageLogged(BuildEvent $event) { 45 function messageLogged(BuildEvent $event) { 46 46 47 47 if ($event->getPriority() > $this->msgOutputLevel || null === $event->getMessage() || trim($event->getMessage() === "")) { 48 48 return; 49 } 49 } 50 50 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; 53 53 $this->printMessage($msg, $this->out, $event->getPriority()); 54 54 $this->targetName = null; 55 55 } -
phing/listener/PearLogListener.php
old new 19 19 * <http://phing.info>. 20 20 */ 21 21 22 require_once 'phing/BuildListener.php'; 22 require_once 'phing/BuildListener.php'; 23 23 24 24 /** 25 25 * Writes build messages to PEAR Log. … … 68 68 * Whether logging has been configured. 69 69 * @var boolean 70 70 */ 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; 77 77 78 78 /** 79 79 * Configure the logger. … … 89 89 if ($name === null) $name = 'phing.log'; 90 90 if ($ident === null) $ident = 'phing'; 91 91 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 } 97 97 98 98 $this->logger = Log::singleton($type, $name, $ident, $conf, self::$levelMap[$this->msgOutputLevel]); 99 99 } -
phing/listener/XmlLogger.php
old new 21 21 22 22 require_once 'phing/BuildLogger.php'; 23 23 require_once 'phing/listener/DefaultLogger.php'; 24 require_once 'phing/system/util/Timer.php'; 24 require_once 'phing/system/util/Timer.php'; 25 25 26 26 /** 27 27 * Generates a file in the current directory with … … 33 33 * @version $Id: XmlLogger.php 147 2007-02-06 20:32:22Z hans $ 34 34 * @package phing.listener 35 35 */ 36 class XmlLogger implements BuildLogger { 36 class XmlLogger implements BuildLogger { 37 37 38 38 /** XML element name for a build. */ 39 39 const BUILD_TAG = "build"; … … 55 55 const ERROR_ATTR = "error"; 56 56 /** XML element name for a stack trace. */ 57 57 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. 61 61 */ 62 62 private $doc; 63 63 … … 66 66 private $taskStartTime = 0; 67 67 68 68 private $buildElement; 69 70 /** 71 * @var int 69 70 /** 71 * @var int 72 72 */ 73 73 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; 84 84 85 85 /** 86 86 * @var string Name of filename to create. … … 117 117 * @param BuildEvent $event An event with any relevant extra information. 118 118 * Will not be <code>null</code>. 119 119 */ 120 public function buildFinished(BuildEvent $event) { 120 public function buildFinished(BuildEvent $event) { 121 121 122 122 $this->buildTimer->stop(); 123 123 … … 134 134 $stacktrace->appendChild($errText); 135 135 $this->buildElement->appendChild($stacktrace); 136 136 } 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 164 164 165 165 /** 166 166 * Fired when a target starts building, remembers the current time and the name of the target. … … 188 188 $target = $event->getTarget(); 189 189 $elapsedTime = Phing::currentTimeMillis() - $this->targetTimerStart; 190 190 $this->targetElement->setAttribute(XmlLogger::TIME_ATTR, DefaultLogger::formatTime($elapsedTime)); 191 $this->buildElement->appendChild($this->targetElement); 191 $this->buildElement->appendChild($this->targetElement); 192 192 $this->targetElement = null; 193 193 } 194 194 … … 204 204 $this->taskElement = $this->doc->createElement(XmlLogger::TASK_TAG); 205 205 $this->taskElement->setAttribute(XmlLogger::NAME_ATTR, $task->getTaskName()); 206 206 $this->taskElement->setAttribute(XmlLogger::LOCATION_ATTR, $task->getLocation()->toString()); 207 } 207 } 208 208 209 209 /** 210 210 * Fired when a task finishes building, this adds the time taken … … 217 217 $task = $event->getTask(); 218 218 $elapsedTime = Phing::currentTimeMillis() - $this->taskTimerStart; 219 219 $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 } 225 225 $this->taskElement = null; 226 226 } 227 227 … … 272 272 $this->buildElement->appendChild($messageElement); 273 273 } 274 274 } 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 } 319 319 320 320 } -
phing/system/io/BufferedReader.php
old new 53 53 } 54 54 55 55 /** 56 * Reads and returns a chunk of data. 56 * Reads and returns a chunk of data. 57 57 * @param int $len Number of bytes to read. Default is to read configured buffer size number of bytes. 58 58 * @return mixed buffer or -1 if EOF. 59 59 */ 60 60 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. 63 63 if ($len === null) $len = $this->bufferSize; 64 64 65 65 if ( ($data = $this->in->read($len)) !== -1 ) { -
phing/system/io/BufferedWriter.php
old new 55 55 56 56 public function getResource() { 57 57 return $this->out->getResource(); 58 }59 60 public function flush() {61 $this->out->flush();62 58 } 63 64 /** 65 * Close attached stream. 59 60 public function flush() { 61 $this->out->flush(); 62 } 63 64 /** 65 * Close attached stream. 66 66 */ 67 67 public function close() { 68 68 return $this->out->close(); -
phing/system/io/FileInputStream.php
old new 18 18 * and is licensed under the LGPL. For more information please see 19 19 * <http://phing.info>. 20 20 */ 21 22 require_once 'phing/system/io/InputStream.php'; 23 require_once 'phing/system/io/PhingFile.php'; 21 22 require_once 'phing/system/io/InputStream.php'; 23 require_once 'phing/system/io/PhingFile.php'; 24 24 25 25 /** 26 * Input stream subclass for file streams. 26 * Input stream subclass for file streams. 27 27 * 28 28 * @package phing.system.io 29 29 */ 30 30 class 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; 36 36 37 37 /** 38 38 * 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. 41 41 * @throws IOException - if unable to open file. 42 42 */ 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 57 57 parent::__construct($stream); 58 58 } 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 63 63 */ 64 64 public function __toString() { 65 65 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; 74 74 } 75 75 } 76 76 -
phing/system/io/FileOutputStream.php
old new 18 18 * and is licensed under the LGPL. For more information please see 19 19 * <http://phing.info>. 20 20 */ 21 22 require_once 'phing/system/io/OutputStream.php'; 23 require_once 'phing/system/io/PhingFile.php'; 21 22 require_once 'phing/system/io/OutputStream.php'; 23 require_once 'phing/system/io/PhingFile.php'; 24 24 25 25 /** 26 * Output stream subclass for file streams. 26 * Output stream subclass for file streams. 27 27 * 28 28 * @package phing.system.io 29 29 */ 30 30 class 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; 36 36 37 37 /** 38 38 * 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. 42 42 * @throws IOException - if unable to open file. 43 43 */ 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 } 60 60 parent::__construct($stream); 61 61 } 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 66 66 */ 67 67 public function __toString() { 68 68 return $this->file->getPath(); -
phing/system/io/FileReader.php
old new 20 20 */ 21 21 22 22 require_once 'phing/system/io/InputStreamReader.php'; 23 require_once 'phing/system/io/FileInputStream.php'; 23 require_once 'phing/system/io/FileInputStream.php'; 24 24 25 25 /** 26 26 * Convenience class for reading files. … … 28 28 */ 29 29 class FileReader extends InputStreamReader { 30 30 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 40 40 } 41 41 -
phing/system/io/FileSystem.php
old new 51 51 52 52 /** 53 53 * Static method to return the FileSystem singelton representing 54 * this platform's local filesystem driver. 54 * this platform's local filesystem driver. 55 55 * @return FileSystem 56 56 */ 57 57 public static function getFileSystem() { -
phing/system/io/FileWriter.php
old new 20 20 */ 21 21 22 22 require_once 'phing/system/io/OutputStreamWriter.php'; 23 require_once 'phing/system/io/FileOutputStream.php'; 23 require_once 'phing/system/io/FileOutputStream.php'; 24 24 25 25 /** 26 26 * Convenience class for performing file write operations. … … 34 34 * @param mixed $file PhingFile or string pathname. 35 35 * @param boolean $append Append to existing file? 36 36 */ 37 function __construct($file, $append = false) { 38 $out = new FileOutputStream($file, $append); 37 function __construct($file, $append = false) { 38 $out = new FileOutputStream($file, $append); 39 39 parent::__construct($out); 40 40 } 41 41 } -
phing/system/io/FilterReader.php
old new 26 26 * @package phing.system.io 27 27 */ 28 28 class FilterReader extends Reader { 29 30 /** 31 * @var Reader 29 30 /** 31 * @var Reader 32 32 */ 33 33 protected $in; 34 34 … … 59 59 60 60 public function close() { 61 61 return $this->in->close(); 62 } 62 } 63 63 64 64 function getResource() { 65 65 return $this->in->getResource(); -
phing/system/io/InputStream.php
old new 20 20 */ 21 21 22 22 /** 23 * Wrapper class for PHP stream that supports read operations. 23 * Wrapper class for PHP stream that supports read operations. 24 24 * 25 25 * @package phing.system.io 26 26 */ 27 27 class 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. 36 31 */ 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. 41 41 */ 42 42 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 58 58 */ 59 59 public function skip($n) { 60 60 $start = $this->currentPosition; … … 78 78 * @param int $len Num chars to read. If not specified this stream will read until EOF. 79 79 * @return string chars read or -1 if eof. 80 80 */ 81 public function read($len = null) { 81 public function read($len = null) { 82 82 83 83 if ($this->eof()) { 84 84 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); 96 96 } 97 97 98 98 return $out; 99 99 } 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."); 108 108 } 109 109 $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
