本文整理汇总了C++中FT_Stream::read方法的典型用法代码示例。如果您正苦于以下问题:C++ FT_Stream::read方法的具体用法?C++ FT_Stream::read怎么用?C++ FT_Stream::read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FT_Stream
的用法示例。
在下文中一共展示了FT_Stream::read方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
static FT_Error
ft_gzip_file_fill_input( FT_GZipFile zip )
{
z_stream* zstream = &zip->zstream;
FT_Stream stream = zip->source;
FT_ULong size;
if ( stream->read )
{
size = stream->read( stream, stream->pos, zip->input,
FT_GZIP_BUFFER_SIZE );
if ( size == 0 )
return Gzip_Err_Invalid_Stream_Operation;
}
else
{
size = stream->size - stream->pos;
if ( size > FT_GZIP_BUFFER_SIZE )
size = FT_GZIP_BUFFER_SIZE;
if ( size == 0 )
return Gzip_Err_Invalid_Stream_Operation;
FT_MEM_COPY( zip->input, stream->base + stream->pos, size );
}
stream->pos += size;
zstream->next_in = zip->input;
zstream->avail_in = size;
return Gzip_Err_Ok;
}
示例2: FT_THROW
static FT_Error
ft_bzip2_file_fill_input( FT_BZip2File zip )
{
bz_stream* bzstream = &zip->bzstream;
FT_Stream stream = zip->source;
FT_ULong size;
if ( stream->read )
{
size = stream->read( stream, stream->pos, zip->input,
FT_BZIP2_BUFFER_SIZE );
if ( size == 0 )
return FT_THROW( Invalid_Stream_Operation );
}
else
{
size = stream->size - stream->pos;
if ( size > FT_BZIP2_BUFFER_SIZE )
size = FT_BZIP2_BUFFER_SIZE;
if ( size == 0 )
return FT_THROW( Invalid_Stream_Operation );
FT_MEM_COPY( zip->input, stream->base + stream->pos, size );
}
stream->pos += size;
bzstream->next_in = (char*)zip->input;
bzstream->avail_in = size;
return FT_Err_Ok;
}
示例3: if
FT_Stream_Seek( FT_Stream stream,
FT_ULong pos )
{
FT_Error error = FT_Err_Ok;
stream->pos = pos;
if ( stream->read )
{
if ( stream->read( stream, pos, 0, 0 ) )
{
FT_ERROR(( "FT_Stream_Seek: invalid i/o; pos = 0x%lx, size = 0x%lx\n",
pos, stream->size ));
error = FT_Err_Invalid_Stream_Operation;
}
}
/* note that seeking to the first position after the file is valid */
else if ( pos > stream->size )
{
FT_ERROR(( "FT_Stream_Seek: invalid i/o; pos = 0x%lx, size = 0x%lx\n",
pos, stream->size ));
error = FT_Err_Invalid_Stream_Operation;
}
return error;
}
示例4:
FT_Stream_ReadChar( FT_Stream stream,
FT_Error* error )
{
FT_Byte result = 0;
FT_ASSERT( stream );
*error = FT_Err_Ok;
if ( stream->read )
{
if ( stream->read( stream, stream->pos, &result, 1L ) != 1L )
goto Fail;
}
else
{
if ( stream->pos < stream->size )
result = stream->base[stream->pos];
else
goto Fail;
}
stream->pos++;
return result;
Fail:
*error = FT_Err_Invalid_Stream_Operation;
FT_ERROR(( "FT_Stream_ReadChar: invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size ));
return 0;
}
示例5:
FT_Stream_EnterFrame( FT_Stream stream,
FT_ULong count )
{
FT_Error error = FT_Err_Ok;
FT_ULong read_bytes;
/* check for nested frame access */
FT_ASSERT( stream && stream->cursor == 0 );
if ( stream->read )
{
/* allocate the frame in memory */
FT_Memory memory = stream->memory;
if ( FT_QALLOC( stream->base, count ) )
goto Exit;
/* read it */
read_bytes = stream->read( stream, stream->pos,
stream->base, count );
if ( read_bytes < count )
{
FT_ERROR(( "FT_Stream_EnterFrame:" ));
FT_ERROR(( " invalid read; expected %lu bytes, got %lu\n",
count, read_bytes ));
FT_FREE( stream->base );
error = FT_Err_Invalid_Stream_Operation;
}
stream->cursor = stream->base;
stream->limit = stream->cursor + count;
stream->pos += read_bytes;
}
else
{
/* check current and new position */
if ( stream->pos >= stream->size ||
stream->pos + count > stream->size )
{
FT_ERROR(( "FT_Stream_EnterFrame:" ));
FT_ERROR(( " invalid i/o; pos = 0x%lx, count = %lu, size = 0x%lx\n",
stream->pos, count, stream->size ));
error = FT_Err_Invalid_Stream_Operation;
goto Exit;
}
/* set cursor */
stream->cursor = stream->base + stream->pos;
stream->limit = stream->cursor + count;
stream->pos += count;
}
Exit:
return error;
}
示例6:
BASE_FUNC(FT_Long) FT_Read_LongLE(FT_Stream stream,
FT_Error *error)
{
FT_Byte reads[4];
FT_Byte *p = 0;
FT_Long result = 0;
FT_Assert(stream);
*error = FT_Err_Ok;
if(stream->pos + 3 < stream->size)
{
if(stream->read)
{
if(stream->read(stream, stream->pos, reads, 4L) != 4L)
{
goto Fail;
}
p = reads;
}
else
{
p = stream->base + stream->pos;
}
if(p)
{
result = NEXT_LongLE(p);
}
}
else
{
goto Fail;
}
stream->pos += 4;
return result;
Fail:
FT_ERROR(("FT_Read_Long:"));
FT_ERROR((" invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size));
*error = FT_Err_Invalid_Stream_Operation;
return 0;
}