123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- require_once 'phing/system/io/OutputStream.php';
- require_once 'phing/system/io/PhingFile.php';
- class FileOutputStream extends OutputStream {
-
-
- protected $file;
-
-
- public function __construct($file, $append = false) {
- if ($file instanceof PhingFile) {
- $this->file = $file;
- } elseif (is_string($file)) {
- $this->file = new PhingFile($file);
- } else {
- throw new Exception("Invalid argument type for \$file.");
- }
- if ($append) {
- $stream = @fopen($this->file->getAbsolutePath(), "ab");
- } else {
- $stream = @fopen($this->file->getAbsolutePath(), "wb");
- }
- if ($stream === false) {
- throw new IOException("Unable to open " . $this->file->__toString() . " for writing: " . $php_errormsg);
- }
- parent::__construct($stream);
- }
-
-
- public function __toString() {
- return $this->file->getPath();
- }
- }
|