| 731 | } |
| 732 | |
| 733 | static unsigned long FileRead( FT_Stream stream, unsigned long offset, unsigned char* buffer, unsigned long count ) |
| 734 | { |
| 735 | IResFile* fp = (IResFile*)stream->descriptor.pointer; |
| 736 | |
| 737 | if( count == 0 ) |
| 738 | { |
| 739 | ssize_t ret = fp->Seek( offset, ICcpStream::SO_BEGIN ); |
| 740 | if( ret == -1 ) |
| 741 | { |
| 742 | return -1; |
| 743 | } |
| 744 | return 0; |
| 745 | } |
| 746 | if( offset != fp->GetPosition() ) |
| 747 | { |
| 748 | fp->Seek( offset, ICcpStream::SO_BEGIN ); |
| 749 | } |
| 750 | |
| 751 | // TODO: See if I can't skip the memcpy there and just read straight into buffer |
| 752 | unsigned char* tmpData = CCP_NEW( "Tr2FontCacheManager/FileRead" ) unsigned char[count]; |
| 753 | ssize_t bytesRead = 0; |
| 754 | // Freetype guarantees that count is never bigger that the stream length |
| 755 | while( (unsigned long)bytesRead < count ) |
| 756 | { |
| 757 | bytesRead += fp->Read( (void*)tmpData, count - bytesRead ); |
| 758 | |
| 759 | memcpy( buffer, tmpData, bytesRead ); |
| 760 | buffer += bytesRead; |
| 761 | } |
| 762 | |
| 763 | CCP_DELETE[] tmpData; |
| 764 | return (unsigned long)bytesRead; |
| 765 | } |
| 766 | |
| 767 | static void FileClose( FT_Stream stream ) |
| 768 | { |
nothing calls this directly
no test coverage detected