/** * Constructs the Zend_Io_FileWriter class with given path to the file. By * default the file is opened in write mode without altering its content * (ie r+b mode if the file exists, and wb mode if not). * * @param string $filename The path to the file. * @throws Zend_Io_Exception if the file cannot be written */ public function __construct($filename, $mode = null) { if ($mode === null) { $mode = file_exists($filename) ? 'r+b' : 'wb'; } if (($fd = fopen($filename, $mode)) === false) { throw new Zend_Io_Exception('Unable to open file for writing: ' . $filename); } parent::__construct($fd); }