Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Attributes
nsJARInputThunk Class Reference
Inheritance diagram for nsJARInputThunk:
Inheritance graph
[legend]
Collaboration diagram for nsJARInputThunk:
Collaboration graph
[legend]

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_NSIINPUTSTREAM 
nsJARInputThunk (nsIFile *jarFile, const nsACString &jarEntry, nsIZipReaderCache *jarCache)
virtual ~nsJARInputThunk ()
void GetJarReader (nsIZipReader **result)
PRInt32 GetContentLength ()
nsresult EnsureJarStream ()
void close ()
 Close the stream.
unsigned long available ()
unsigned long read (in charPtr aBuf, in unsigned long aCount)
 Read data from the stream.
unsigned long readSegments (in nsWriteSegmentFun aWriter, in voidPtr aClosure, in unsigned long aCount)
 Low-level read method that has access to the stream's underlying buffer.
boolean isNonBlocking ()

Private Attributes

nsCOMPtr< nsIZipReaderCachemJarCache
nsCOMPtr< nsIZipReadermJarReader
nsCOMPtr< nsIFilemJarFile
nsCOMPtr< nsIInputStreammJarStream
nsCString mJarEntry
PRInt32 mContentLength

Detailed Description

Definition at line 72 of file nsJARChannel.cpp.


Constructor & Destructor Documentation

NS_DECL_ISUPPORTS NS_DECL_NSIINPUTSTREAM nsJARInputThunk::nsJARInputThunk ( nsIFile jarFile,
const nsACString &  jarEntry,
nsIZipReaderCache jarCache 
) [inline]

Definition at line 78 of file nsJARChannel.cpp.

        : mJarCache(jarCache)
        , mJarFile(jarFile)
        , mJarEntry(jarEntry)
        , mContentLength(-1)
    {
        NS_ASSERTION(mJarFile, "no jar file");
    }
virtual nsJARInputThunk::~nsJARInputThunk ( ) [inline, virtual]

Definition at line 88 of file nsJARChannel.cpp.

    {
        if (!mJarCache && mJarReader)
            mJarReader->Close();
    }

Member Function Documentation

unsigned long nsIInputStream::available ( ) [inherited]
Returns:
number of bytes currently available in the stream
void nsIInputStream::close ( ) [inherited]

Close the stream.

Definition at line 119 of file nsJARChannel.cpp.

{
    if (mJarStream)
        return NS_OK;

    nsresult rv;
    if (mJarCache)
        rv = mJarCache->GetZip(mJarFile, getter_AddRefs(mJarReader));
    else {
        // create an uncached jar reader
        mJarReader = do_CreateInstance(kZipReaderCID, &rv);
        if (NS_FAILED(rv)) return rv;

        rv = mJarReader->Init(mJarFile);
        if (NS_FAILED(rv)) return rv;

        rv = mJarReader->Open();
    }
    if (NS_FAILED(rv)) return rv;

    rv = mJarReader->GetInputStream(mJarEntry.get(),
                                    getter_AddRefs(mJarStream));
    if (NS_FAILED(rv)) return rv;

    // ask the JarStream for the content length
    mJarStream->Available((PRUint32 *) &mContentLength);

    return NS_OK;
}

Here is the call graph for this function:

Definition at line 99 of file nsJARChannel.cpp.

    {
        return mContentLength;
    }

Definition at line 94 of file nsJARChannel.cpp.

    {
        NS_IF_ADDREF(*result = mJarReader);
    }
Returns:
true if stream is non-blocking
unsigned long nsIInputStream::read ( in charPtr  aBuf,
in unsigned long  aCount 
) [inherited]

Read data from the stream.

Parameters:
aBufthe buffer into which the data is to be read
aCountthe maximum number of bytes to be read
Returns:
number of bytes read (may be less than aCount).
0 if reached end of file
Exceptions:
NS_BASE_STREAM_WOULD_BLOCKif reading from the input stream would block the calling thread (non-blocking mode only)
<other-error>on failure
unsigned long nsIInputStream::readSegments ( in nsWriteSegmentFun  aWriter,
in voidPtr  aClosure,
in unsigned long  aCount 
) [inherited]

Low-level read method that has access to the stream's underlying buffer.

The writer function may be called multiple times for segmented buffers. ReadSegments is expected to keep calling the writer until either there is nothing left to read or the writer returns an error. ReadSegments should not call the writer with zero bytes to consume.

Parameters:
aWriterthe "consumer" of the data to be read
aClosureopaque parameter passed to writer
aCountthe maximum number of bytes to be read
Returns:
number of bytes read (may be less than aCount)
0 if reached end of file (or if aWriter refused to consume data)
Exceptions:
NS_BASE_STREAM_WOULD_BLOCKif reading from the input stream would block the calling thread (non-blocking mode only)
<other-error>on failure

NOTE: this function may be unimplemented if a stream has no underlying buffer (e.g., socket input stream).


Member Data Documentation

Definition at line 113 of file nsJARChannel.cpp.

Definition at line 108 of file nsJARChannel.cpp.

Definition at line 112 of file nsJARChannel.cpp.

Definition at line 110 of file nsJARChannel.cpp.

Definition at line 109 of file nsJARChannel.cpp.

Definition at line 111 of file nsJARChannel.cpp.


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