Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions
xptiZipLoader Class Reference

#include <xptiprivate.h>

List of all members.

Public Member Functions

 xptiZipLoader ()

Static Public Member Functions

static XPTHeaderReadXPTFileFromInputStream (nsIInputStream *stream, xptiWorkingSet *aWorkingSet)

Detailed Description

Definition at line 803 of file xptiprivate.h.


Constructor & Destructor Documentation


Member Function Documentation

Definition at line 45 of file xptiZipLoader.cpp.

{
    XPTCursor cursor;
    PRUint32 totalRead = 0;
    XPTState *state = nsnull;
    XPTHeader *header = nsnull;

    PRUint32 flen;
    stream->Available(&flen);
    
    char *whole = new char[flen];
    if (!whole)
    {
        return nsnull;
    }

    // all exits from on here should be via 'goto out' 

    while(flen - totalRead)
    {
        PRUint32 avail;
        PRUint32 read;

        if(NS_FAILED(stream->Available(&avail)))
        {
            goto out;
        }

        if(avail > flen)
        {
            goto out;
        }

        if(NS_FAILED(stream->Read(whole+totalRead, avail, &read)))
        {
            goto out;
        }

        totalRead += read;
    }
    
    // Go ahead and close the stream now.
    stream = nsnull;

    if(!(state = XPT_NewXDRState(XPT_DECODE, whole, flen)))
    {
        goto out;
    }
    
    if(!XPT_MakeCursor(state, XPT_HEADER, 0, &cursor))
    {
        goto out;
    }
    
    if (!XPT_DoHeader(aWorkingSet->GetStructArena(), &cursor, &header))
    {
        header = nsnull;
        goto out;
    }

 out:
    if(state)
        XPT_DestroyXDRState(state);
    if(whole)
        delete [] whole;
    return header;
}

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following files: