/** * Constructs the HausDesign_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 HausDesign_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) { require_once 'HausDesign/Io/Exception.php'; throw new HausDesign_Io_Exception('Unable to open file for writing: ' . $filename); } parent::__construct($fd); }