FT_Stream_Open( FT_Stream stream, const char* filepathname ) { FT_FILE* file; if ( !stream ) return FT_Err_Invalid_Stream_Handle; file = ft_fopen( filepathname, "rb" ); if ( !file ) { FT_ERROR(( "FT_Stream_Open:" " could not open `%s'\n", filepathname )); return FT_Err_Cannot_Open_Resource; } ft_fseek( file, 0, SEEK_END ); stream->size = ft_ftell( file ); ft_fseek( file, 0, SEEK_SET ); stream->descriptor.pointer = file; stream->pathname.pointer = (char*)filepathname; stream->pos = 0; stream->read = ft_ansi_stream_io; stream->close = ft_ansi_stream_close; FT_TRACE1(( "FT_Stream_Open:" )); FT_TRACE1(( " opened `%s' (%d bytes) successfully\n", filepathname, stream->size )); return FT_Err_Ok; }
ft_FSp_stream_io( FT_Stream stream, unsigned long offset, unsigned char* buffer, unsigned long count ) { FT_FILE* file; file = STREAM_FILE( stream ); ft_fseek( file, offset, SEEK_SET ); return (unsigned long)ft_fread( buffer, 1, count, file ); }
ft_ansi_stream_io( FT_Stream stream, unsigned long offset, unsigned char* buffer, unsigned long count ) { FT_FILE* file; if ( !count && offset > stream->size ) return 1; file = STREAM_FILE( stream ); if ( stream->pos != offset ) ft_fseek( file, (long)offset, SEEK_SET ); return (unsigned long)ft_fread( buffer, 1, count, file ); }