Ejemplo n.º 1
0
void File_Extractor::set_info( BOOST::uint64_t new_size, unsigned date, unsigned crc )
{
	size_  = new_size;
	date_  = (date != 0xFFFFFFFF ? date : 0);
	crc32_ = crc;
	set_remain( new_size );
}
Ejemplo n.º 2
0
const char * Nes_File_Reader::read_v( void* p, int n )
{
	if ( (unsigned long) n > h.size )
		n = h.size;
	h.size -= n;
	set_remain( h.size );
	return in->read( p, n );
}
Ejemplo n.º 3
0
const char * Nes_File_Reader::skip_v( int s )
{
	if ( (unsigned long) s > h.size )
		return "Tried to skip past end of data";
	h.size -= s;
	set_remain( h.size );
	return in->skip( s );
}
Ejemplo n.º 4
0
Remaining_Reader::Remaining_Reader( void const* h, int size, Data_Reader* r ) :
	in( r )
{
	header        = h;
	header_remain = size;
	
	set_remain( size + r->remain() );
}
Ejemplo n.º 5
0
blargg_err_t Gzip_Reader::open( File_Reader* new_in )
{
	close();
	
	in = new_in;
	RETURN_ERR( in->seek( 0 ) );
	RETURN_ERR( inflater.begin( gzip_reader_read, new_in ) );
	RETURN_ERR( inflater.set_mode( inflater.mode_auto ) );
	RETURN_ERR( calc_size() );
	set_remain( size_ );
	
	return blargg_ok;
}
Ejemplo n.º 6
0
const char * Nes_File_Reader::read_header()
{
	RETURN_ERR( in->read( &h, sizeof h ) );
	h.swap();
	block_type_ = data_block;
	if ( h.size == group_begin_size )
	{
		block_type_ = group_begin;
		h.size = 0;
	}
	if ( (long) h.tag == group_end_tag )
	{
		block_type_ = group_end;
		h.tag = 0;
	}
	set_remain( h.size );
	return 0;
}
Ejemplo n.º 7
0
blargg_err_t File_Extractor::rewind_file()
{
	RETURN_ERR( stat() );
	
	if ( tell() > 0 )
	{
		if ( data_ptr_ )
		{
			set_remain( size() );
		}
		else
		{
			RETURN_ERR( seek_arc( tell_arc() ) );
			RETURN_ERR( stat() );
		}
	}
	
	return blargg_ok;
}
Ejemplo n.º 8
0
blargg_err_t File_Extractor::data( const void** data_out )
{
	assert( !done() );
	
	*data_out = NULL;
	if ( !data_ptr_ )
	{
		BOOST::uint64_t old_tell = tell();
		
		RETURN_ERR( rewind_file() );
		
		void const* ptr;
		RETURN_ERR( data_v( &ptr ) );
		data_ptr_ = ptr;
		
		// Now that data is in memory, we can seek by simply setting remain
		set_remain( size() - old_tell );
	}
	
	*data_out = data_ptr_;
	return blargg_ok;
}
Ejemplo n.º 9
0
foobar_Data_Reader::foobar_Data_Reader( const service_ptr_t<file> & p_file, abort_callback & p_abort ) : m_file( p_file ), m_abort( p_abort )
{
	t_filesize remain = m_file->get_size_ex( m_abort ) - m_file->get_position( m_abort );
	if ( remain > INT_MAX ) remain = INT_MAX;
	set_remain( remain );
}
Ejemplo n.º 10
0
Callback_Reader::Callback_Reader( callback_t c, BOOST::uint64_t s, void* d ) :
	callback( c ),
	user_data( d )
{
	set_remain( s );
}
Ejemplo n.º 11
0
Subset_Reader::Subset_Reader( Data_Reader* dr, BOOST::uint64_t size ) :
	in( dr )
{
	set_remain( min( size, dr->remain() ) );
}