OStream *New_OStream(const char *sname, const unsigned int stype, const bool sappend)
{
	Pointer<OStream> ostreamptr(POV_PLATFORM_BASE.CreateOStream(stype));
	unsigned int Flags = IOBase::none;

	if(ostreamptr == NULL)
		return NULL;

	if(sappend)
		Flags |= IOBase::append;

	if(ostreamptr->open(sname, Flags) == 0)
		return NULL;

	return ostreamptr.release();
}
Example #2
0
OStream *NewOStream(const Path& p, const unsigned int stype, const bool sappend)
{
    Pointer<OStream> ostreamptr(POV_PLATFORM_BASE.CreateOStream(stype));
    unsigned int Flags = IOBase::none;

    if(ostreamptr == NULL)
        return NULL;

    if(sappend)
        Flags |= IOBase::append;

    if (POV_ALLOW_FILE_WRITE(p().c_str(), stype) == false) // TODO FIXME - this is handled by the frontend, but that code isn't completely there yet [trf]
    {
        string str ("IO Restrictions prohibit write access to '") ;
        str += UCS2toASCIIString(p());
        str += "'";
        throw POV_EXCEPTION(kCannotOpenFileErr, str);
    }
    if(ostreamptr->open(p().c_str(), Flags) == 0)
        return NULL;

    return ostreamptr.release();
}