writeCount = m_fileStream->write(m_dataBuffer, readCount);
if (m_needStatusLine) { m_needStatusLine = PR_FALSE;     if (!strncmp(m_dataBuffer, "From ", 5)) { PRInt32 charIndex; for (charIndex = 5; charIndex < readCount; charIndex++) { if (m_dataBuffer[charIndex] == nsCRT::CR || m_dataBuffer[charIndex] == nsCRT::LF) { charIndex++; if (m_dataBuffer[charIndex- 1] == nsCRT::CR && m_dataBuffer[charIndex] == nsCRT::LF) charIndex++; break; } } char statusLine[50]; writeCount = m_fileStream->write(m_dataBuffer, charIndex); m_statusOffset = charIndex; PR_snprintf(statusLine, sizeof(statusLine), X_MOZILLA_STATUS_FORMAT MSG_LINEBREAK, msgFlags & 0xFFFF); m_statusLineSize = m_fileStream->write(statusLine, strlen(statusLine)); PR_snprintf(statusLine, sizeof(statusLine), X_MOZILLA_STATUS2_FORMAT MSG_LINEBREAK, msgFlags & 0xFFFF0000); m_statusLineSize += m_fileStream->write(statusLine, strlen(statusLine)); writeCount += m_fileStream->write(m_dataBuffer + charIndex, readCount - charIndex);  } else { NS_ASSERTION(PR_FALSE, "not an envelope");  nsCOMPtr <nsIMsgDatabase> srcDB; m_folder->GetMsgDatabase(nsnull, getter_AddRefs(srcDB)); if (srcDB) { srcDB->SetSummaryValid(PR_FALSE); srcDB->ForceClosed(); } } } else { writeCount = m_fileStream->write(m_dataBuffer, readCount); }
nsFolderCompactState::OnDataAvailable(nsIChannel *channel, nsISupports *ctxt,                                      nsIInputStream *inStr,                                       PRUint32 sourceOffset, PRUint32 count){  nsresult rv = NS_ERROR_FAILURE;  if (!m_fileStream || !inStr) return rv;  PRUint32 maxReadCount, readCount, writeCount;  rv = NS_OK;  while (NS_SUCCEEDED(rv) && (PRInt32) count > 0)  {    maxReadCount = count > FOUR_K ? FOUR_K : count;    rv = inStr->Read(m_dataBuffer, maxReadCount, &readCount);    if (NS_SUCCEEDED(rv))    {      writeCount = m_fileStream->write(m_dataBuffer, readCount);      count -= readCount;      NS_ASSERTION (writeCount == readCount,                     "Oops, write fail, folder can be corrupted!\n");    }  }  return rv;}