PRBool isOpened = PR_FALSE; stream->GetIsOpen(&isOpened); if (!isOpened) { delete stream; return NS_ERROR_FAILURE; }
NS_RELEASE(stream); return NS_ERROR_FAILURE;
NS_COM nsresult NS_NewIOFileStream(    nsISupports** aResult,    const nsFileSpec& inFile,    PRInt32 nsprMode /*default = (PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE)*/,    PRInt32 accessMode /*Default = 0666 (octal)*/)    // Factory method to get an object that implements both nsIInputStream    // and nsIOutputStream, associated with a file.//----------------------------------------------------------------------------------------{    NS_PRECONDITION(aResult != nsnull, "null ptr");    if (!aResult)        return NS_ERROR_NULL_POINTER;    FileImpl* stream = new FileImpl(inFile, nsprMode, accessMode);    if (! stream)        return NS_ERROR_OUT_OF_MEMORY;    else     {        PRBool isOpened = PR_FALSE;        stream->GetIsOpen(&isOpened);        if (!isOpened)        {            delete stream;            return NS_ERROR_FAILURE;        }    }    NS_ADDREF(stream);    *aResult = (nsISupports*)(void*)stream;    return NS_OK;}