nsCOMPtr<nsISeekableStream> seekable = do_QueryInterface(mSink); if (seekable) seekable->Seek(nsISeekableStream::NS_SEEK_SET, mOffset);
if (mOffset != PR_UINT32_MAX) { nsCOMPtr<nsISeekableStream> seekable = do_QueryInterface(mSink); if (seekable) seekable->Seek(nsISeekableStream::NS_SEEK_SET, mOffset); }
nsOutputStreamTransport::Write(const char *buf, PRUint32 count, PRUint32 *result){    if (mFirstTime) {        mFirstTime = PR_FALSE;        if (mOffset) {            nsCOMPtr<nsISeekableStream> seekable = do_QueryInterface(mSink);            if (seekable)                seekable->Seek(nsISeekableStream::NS_SEEK_SET, mOffset);            // reset offset to zero so we can use it to enforce limit            mOffset = 0;        }    }    // limit amount written    PRUint32 max = mLimit - mOffset;    if (max == 0) {        *result = 0;        return NS_OK;    }            if (count > max)        count = max;    nsresult rv = mSink->Write(buf, count, result);    if (NS_SUCCEEDED(rv)) {        mOffset += *result;        if (mEventSink)            mEventSink->OnTransportStatus(this, STATUS_WRITING, mOffset, mLimit);    }    return rv;}