--------------------------------------
| 411 | |
| 412 | //-------------------------------------- |
| 413 | bool ZipSubWStream::_write(const U32 numBytes, const void *pBuffer) |
| 414 | { |
| 415 | m_lastBytesWritten = 0; |
| 416 | if (numBytes == 0) |
| 417 | return true; |
| 418 | |
| 419 | AssertFatal(pBuffer != NULL, "NULL input buffer"); |
| 420 | if (getStatus() == Closed) |
| 421 | { |
| 422 | AssertFatal(false, "Attempted write to a closed stream"); |
| 423 | return false; |
| 424 | } |
| 425 | |
| 426 | m_pZipStream->next_in = (U8*)pBuffer; |
| 427 | m_pZipStream->avail_in = numBytes; |
| 428 | |
| 429 | // write as many bufferSize chunks as possible |
| 430 | while(m_pZipStream->avail_in != 0) |
| 431 | { |
| 432 | if(m_pZipStream->avail_out == 0) |
| 433 | { |
| 434 | if(!m_pStream->write(csm_bufferSize, m_pOutputBuffer)) |
| 435 | return(false); |
| 436 | |
| 437 | m_pZipStream->next_out = m_pOutputBuffer; |
| 438 | m_pZipStream->avail_out = csm_bufferSize; |
| 439 | } |
| 440 | |
| 441 | S32 retVal = deflate(m_pZipStream, Z_NO_FLUSH); |
| 442 | AssertFatal(retVal != Z_BUF_ERROR, "ZipSubWStream::_write: invalid buffer"); |
| 443 | } |
| 444 | |
| 445 | setStatus(Ok); |
| 446 | m_currPosition += m_pZipStream->total_out; |
| 447 | |
| 448 | m_lastBytesWritten = m_pZipStream->total_out; |
| 449 | |
| 450 | return true; |
| 451 | } |
| 452 | |
| 453 | //-------------------------------------- |
| 454 | bool ZipSubWStream::hasCapability(const Capability in_cap) const |