예제 #1
0
OStream *NewOStream(const Path& p, unsigned int stype, bool sappend)
{
    unsigned int Flags = IOBase::none;

    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);
    }

    return new OStream(p().c_str(), Flags);
}
int ProcessOptions::WriteFile(const char *filename, POVMSObjectPtr obj)
{
	struct INI_Parser_Table *table = parse_ini_table;
	OTextStream *ini_file;
	int err = kNoErr;

	if(!POV_ALLOW_FILE_WRITE(filename, POV_File_Text_INI))
		return kCannotOpenFileErr;

	ini_file = OpenFileForWrite(filename, obj);
	if(ini_file == NULL)
		return kCannotOpenFileErr;
	err = WriteFile (ini_file, obj);
	delete ini_file;

	return err;
}
예제 #3
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();
}
예제 #4
0
OStream *New_Checked_OStream(char *filename, unsigned int stype, bool append)
{
	if(POV_ALLOW_FILE_WRITE(filename, stype) == true)
		return New_OStream(filename, stype, append);
	return NULL;
}