nsIJAR* hZip = nsnull;
nsCOMPtr<nsIZipReader> hZip;
GetInstallScriptFromJarfile(const char* jarFile, char** scriptBuffer, PRUint32 *scriptLength){    nsIJAR* hZip = nsnull;    PRInt32 result = NS_OK;        *scriptBuffer = nsnull;    *scriptLength = 0;    static NS_DEFINE_IID(kIJARIID, NS_IJAR_IID);    static NS_DEFINE_IID(kJARCID,  NS_JAR_CID);    nsresult rv = nsComponentManager::CreateInstance(kJARCID, nsnull, kIJARIID,                                                      (void**) &hZip);    // Open the jarfile    if ( NS_SUCCEEDED(rv) && hZip)        rv = hZip->Open( jarFile, &result );    if ( NS_FAILED(rv) || result != 0 )    {        // early bail-out        NS_IF_RELEASE(hZip);        return nsInstall::CANT_READ_ARCHIVE;    }    // Extract the install.js file to the temporary directory    nsSpecialSystemDirectory installJSFileSpec(nsSpecialSystemDirectory::OS_TemporaryDirectory);    installJSFileSpec += "install.js";    installJSFileSpec.MakeUnique();    // Extract the install.js file.    rv = hZip->Extract( "install.js", nsNSPRPath(installJSFileSpec), &result );    if ( NS_SUCCEEDED(rv) && result == 0 )    {        // Read it into a buffer        char* buffer;        PRUint32 bufferLength;        PRUint32 readLength;        result = nsInstall::CANT_READ_ARCHIVE;        nsInputFileStream fileStream(installJSFileSpec);        nsCOMPtr<nsIInputStream> instream = fileStream.GetIStream();        if ( instream )        {            instream->Available(&bufferLength);            buffer = new char[bufferLength + 1];                if (buffer != nsnull)            {                rv = instream->Read(buffer, bufferLength, &readLength);                if (NS_SUCCEEDED(rv) && readLength > 0)                {                    *scriptBuffer = buffer;                    *scriptLength = readLength;                    result = NS_OK;                }                else                {                    delete [] buffer;                }            }            fileStream.close();        }        installJSFileSpec.Delete(PR_FALSE);    }    else    {        result = nsInstall::NO_INSTALL_SCRIPT;    }    NS_IF_RELEASE( hZip );            return result;   }