| 77 | // |
| 78 | //***************************************************************************** |
| 79 | bool COutStream::WriteData( const void * data, u32 length ) |
| 80 | { |
| 81 | if ( mFile != NULL ) |
| 82 | { |
| 83 | const u8 * current_ptr( reinterpret_cast< const u8 * >( data ) ); |
| 84 | u32 bytes_remaining( length ); |
| 85 | while( bytes_remaining > 0 ) |
| 86 | { |
| 87 | u32 buffer_bytes_remaining( BUFFER_SIZE - mBufferCount ); |
| 88 | u32 bytes_to_process( Min( bytes_remaining, buffer_bytes_remaining ) ); |
| 89 | |
| 90 | // |
| 91 | // Append as many bytes as possible |
| 92 | // |
| 93 | if( bytes_to_process > 0 ) |
| 94 | { |
| 95 | memcpy( mBuffer + mBufferCount, current_ptr, bytes_to_process ); |
| 96 | |
| 97 | current_ptr += bytes_to_process; |
| 98 | bytes_remaining -= bytes_to_process; |
| 99 | mBufferCount += bytes_to_process; |
| 100 | } |
| 101 | |
| 102 | // |
| 103 | // Flush the buffer if full |
| 104 | // |
| 105 | if( mBufferCount >= BUFFER_SIZE ) |
| 106 | { |
| 107 | if( !Flush() ) |
| 108 | { |
| 109 | return false; |
| 110 | } |
| 111 | } |
| 112 | } |
| 113 | return true; |
| 114 | } |
| 115 | |
| 116 | return false; |
| 117 | } |
| 118 | |
| 119 | //***************************************************************************** |
| 120 | // |
no outgoing calls
no test coverage detected