Example #1
0
bool MCReferencedImageRep::GetDataStream(IO_handle &r_stream)
{
	IO_handle t_stream = nil;
	if (MCSecureModeCanAccessDisk())
		t_stream = MCS_open(m_file_name, IO_READ_MODE, false, false, 0);
	
	// MW-2013-09-25: [[ Bug 10983 ]] Only ever try to load the rep as a url once.
	if (t_stream == nil && !m_url_load_attempted)
	{
		// MW-2013-09-25: [[ Bug 10983 ]] Mark the rep has having attempted url load.
		m_url_load_attempted = true;
		
		MCExecPoint ep(MCdefaultstackptr, nil, nil);
		ep.setsvalue(m_file_name);
		
		MCU_geturl(ep);
		
		if (ep.getsvalue().getlength() == 0)
			return false;

		/* UNCHECKED */ MCMemoryAllocateCopy(ep.getsvalue().getstring(), ep.getsvalue().getlength(), m_url_data);
		m_url_data_size = ep.getsvalue().getlength();

		t_stream = MCS_fakeopen(MCString((char*)m_url_data, m_url_data_size));
	}

	if (t_stream != nil)
		r_stream = t_stream;

	return t_stream != nil;
}
Example #2
0
bool MCReferencedImageRep::GetDataStream(IO_handle &r_stream)
{
	IO_handle t_stream = nil;
	if (MCSecureModeCanAccessDisk())
		t_stream = MCS_open(m_file_name, kMCOpenFileModeRead, false, false, 0);
	
	if (t_stream == nil)
    {
        // MW-2013-09-25: [[ Bug 10983 ]] Only ever try to load the rep as a url once.
        if (!m_url_load_attempted)
        {
            // MW-2013-09-25: [[ Bug 10983 ]] Mark the rep has having attempted url load.
            m_url_load_attempted = true;

            MCExecContext ctxt(MCdefaultstackptr, nil, nil);
            MCAutoValueRef t_data;
            MCU_geturl(ctxt, m_file_name, &t_data);
            if (ctxt.HasError() || MCValueIsEmpty(*t_data))
                return false;
            MCAutoDataRef t_dataref;
            /* UNCHECKED */ ctxt . ConvertToData(*t_data, &t_dataref);

            /* UNCHECKED */ MCMemoryAllocateCopy(MCDataGetBytePtr(*t_dataref), MCDataGetLength(*t_dataref), m_url_data);
            m_url_data_size = MCDataGetLength(*t_dataref);
        }

        // IM-2014-09-30: [[ Bug 13501 ]] If we already have the url data then make sure we use it.
        if (m_url_data != nil)
            t_stream =  MCS_fakeopen((const char *)m_url_data, m_url_data_size);
	}

	if (t_stream != nil)
		r_stream = t_stream;

	return t_stream != nil;
}
Example #3
0
MCVectorImageRep::MCVectorImageRep(const void *p_data, uindex_t p_size)
{
	/* UNCHECKED */ MCMemoryAllocateCopy(p_data, p_size, m_data);
	m_size = p_size;
}