<?php
/**
* provides {@link r3_generate_Output} class
*
*
* Copyright (c) 2007 Yahoo! Inc. All rights reserved.
* The copyrights embodied in the content of this file are licensed under the BSD
* open source license
*
* @package r3
* @subpackage generate
*/
/**
*/
require_once("r3/generate/Output.php");
/**
* provides {@link r3_generate_Output} class
*
* @package r3
* @subpackage generate
*/
class r3_generate_FileOutput extends r3_generate_Output {
function doOpen( r3_generate_GenerateContext $context ) {
$htdocs = r3::getHtdocs();
$target = $context->getTarget();
$loc = $target->startLocation();
$path = $loc->getFilePath();
$page_sub_path = $target->getSubDir();
$fulldir = $htdocs->concat( $path );
if ( count($page_sub_path) ) {
$fulldir = $fulldir->concat($page_sub_path);
}
$fulldir->mkdir();
$fullpath = $fulldir->concatUTF8( $target->getBaseName() );
$this->fh = fopen( $fullpath->toString(), 'w' );
}
function doClose() {
fclose( $this->fh );
}
function doOutput( $str ) {
if ( is_bool( fputs( $this->fh, $str ) ) ) {
throw new r3_util_Exception("cannot write to file handle");
}
}
}
?>