MCPcopy Create free account
hub / github.com/carbonengine/trinity / FileRead

Function FileRead

trinity/Font/Tr2FontManager.cpp:733–765  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

731}
732
733static 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
767static void FileClose( FT_Stream stream )
768{

Callers

nothing calls this directly

Calls 3

SeekMethod · 0.45
GetPositionMethod · 0.45
ReadMethod · 0.45

Tested by

no test coverage detected