rv = fileTrans->AsyncWrite(inStr, listener, nsnull);
rv = NS_AsyncWriteFromStream(fileTrans, inStr, listener, nsnull);
TestAsyncWrite(const char* fileName, PRUint32 offset, PRInt32 length){    nsresult rv;    NS_WITH_SERVICE(nsIFileTransportService, fts, kFileTransportServiceCID, &rv);    if (NS_FAILED(rv)) return rv;    nsCAutoString outFile(fileName);    outFile.Append(".out");    nsIChannel* fileTrans;    nsCOMPtr<nsILocalFile> file;    rv = NS_NewLocalFile(outFile, PR_FALSE, getter_AddRefs(file));    if (NS_FAILED(rv)) return rv;    rv = fts->CreateTransport(file,                              PR_CREATE_FILE | PR_WRONLY | PR_TRUNCATE,                              0664, &fileTrans);    if (NS_FAILED(rv)) return rv;    MyListener* listener = new MyListener();    if (listener == nsnull)        return NS_ERROR_OUT_OF_MEMORY;    NS_ADDREF(listener);    rv = listener->Init(outFile);    if (NS_FAILED(rv)) return rv;    nsCOMPtr<nsILocalFile> f;    rv = NS_NewLocalFile(fileName, PR_FALSE, getter_AddRefs(f));    if (NS_FAILED(rv)) return rv;    nsCOMPtr<nsIInputStream> inStr;    rv = NS_NewLocalFileInputStream(getter_AddRefs(inStr), f);    if (NS_FAILED(rv)) return rv;    gDone = PR_FALSE;    rv = fileTrans->SetTransferOffset(offset);    if (NS_FAILED(rv)) return rv;    rv = fileTrans->SetTransferCount(length);    if (NS_FAILED(rv)) return rv;    rv = fileTrans->AsyncWrite(inStr, listener, nsnull);    if (NS_FAILED(rv)) return rv;    while (!gDone) {        PLEvent* event;        rv = gEventQ->GetEvent(&event);        if (NS_FAILED(rv)) return rv;        rv = gEventQ->HandleEvent(event);        if (NS_FAILED(rv)) return rv;    }    NS_RELEASE(listener);    NS_RELEASE(fileTrans);    return NS_OK;}