зеркало из https://github.com/mozilla/gecko-dev.git
Libjar cleanup. Added Close method. Bug#18273. r=mstoltz,gayatrib,dveditz
This commit is contained in:
Родитель
925f33ebbc
Коммит
4a274d01f1
|
@ -44,8 +44,7 @@ EXPORTS = zipfile.h \
|
|||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
XPIDLSRCS = \
|
||||
nsIZip.idl \
|
||||
nsIJAR.idl \
|
||||
nsIZipReader.idl \
|
||||
$(NULL)
|
||||
|
||||
|
||||
|
|
|
@ -35,8 +35,7 @@ DLLNAME=jar$(VERSION_NUMBER)
|
|||
DLL=$(OBJDIR)\$(DLLNAME).dll
|
||||
MAPFILE=$(DLLNAME).map
|
||||
|
||||
XPIDLSRCS=.\nsIZip.idl \
|
||||
.\nsIJAR.idl \
|
||||
XPIDLSRCS=.\nsIZipReader.idl \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS=zipfile.h
|
||||
|
|
|
@ -61,7 +61,6 @@ interface nsIJAR : nsIZip
|
|||
/* This interface will be filled with other "JAR"-related functions. */
|
||||
/* The term "JAR" is in reference to security as opposed to "Zip"
|
||||
* which is a non-secure archive format. */
|
||||
|
||||
};
|
||||
|
||||
[uuid(70993CAD-2922-11d3-A431-0060B0EB5963)]
|
||||
|
|
|
@ -36,53 +36,132 @@
|
|||
#include "nsRepository.h"
|
||||
#include "nsIComponentManager.h"
|
||||
|
||||
#include "nsIZip.h"
|
||||
#include "nsJAR.h"
|
||||
#include "nsJARInputStream.h"
|
||||
//#include "nsIFile.h"
|
||||
|
||||
#ifndef __gen_nsIFile_h__
|
||||
#define NS_ERROR_FILE_UNRECONGNIZED_PATH NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 1)
|
||||
#define NS_ERROR_FILE_UNRESOLVABLE_SYMLINK NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 2)
|
||||
#define NS_ERROR_FILE_EXECUTION_FAILED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 3)
|
||||
#define NS_ERROR_FILE_UNKNOWN_TYPE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 4)
|
||||
#define NS_ERROR_FILE_DESTINATION_NOT_DIR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 5)
|
||||
#define NS_ERROR_FILE_TARGET_DOES_NOT_EXIST NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 6)
|
||||
#define NS_ERROR_FILE_COPY_OR_MOVE_FAILED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 7)
|
||||
#define NS_ERROR_FILE_ALREADY_EXISTS NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 8)
|
||||
#define NS_ERROR_FILE_INVALID_PATH NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 9)
|
||||
#define NS_ERROR_FILE_DISK_FULL NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 10)
|
||||
#define NS_ERROR_FILE_CORRUPTED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 11)
|
||||
#endif
|
||||
|
||||
static nsresult
|
||||
ziperr2nsresult(PRInt32 ziperr)
|
||||
{
|
||||
switch (ziperr) {
|
||||
case ZIP_OK: return NS_OK;
|
||||
case ZIP_ERR_MEMORY: return NS_ERROR_OUT_OF_MEMORY;
|
||||
case ZIP_ERR_DISK: return NS_ERROR_FILE_DISK_FULL;
|
||||
case ZIP_ERR_CORRUPT: return NS_ERROR_FILE_CORRUPTED;
|
||||
case ZIP_ERR_PARAM: return NS_ERROR_ILLEGAL_VALUE;
|
||||
case ZIP_ERR_FNF: return NS_ERROR_FILE_TARGET_DOES_NOT_EXIST;
|
||||
case ZIP_ERR_UNSUPPORTED: return NS_ERROR_NOT_IMPLEMENTED;
|
||||
default: return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
static PRInt32
|
||||
nsresult2ziperr(nsresult rv)
|
||||
{
|
||||
switch (rv) {
|
||||
case NS_OK: return ZIP_OK;
|
||||
case NS_ERROR_OUT_OF_MEMORY: return ZIP_ERR_MEMORY;
|
||||
case NS_ERROR_FILE_DISK_FULL: return ZIP_ERR_DISK;
|
||||
case NS_ERROR_FILE_CORRUPTED: return ZIP_ERR_CORRUPT;
|
||||
case NS_ERROR_ILLEGAL_VALUE: return ZIP_ERR_PARAM;
|
||||
case NS_ERROR_FILE_TARGET_DOES_NOT_EXIST: return ZIP_ERR_FNF;
|
||||
case NS_ERROR_NOT_IMPLEMENTED: return ZIP_ERR_UNSUPPORTED;
|
||||
default: return ZIP_ERR_GENERAL;
|
||||
}
|
||||
}
|
||||
|
||||
nsJAR::nsJAR()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
|
||||
nsJAR::~nsJAR()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsJAR, nsIZip, nsIJAR);
|
||||
NS_IMPL_ISUPPORTS1(nsJAR, nsIZipReader);
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJAR::Open(const char *aZipFileName, PRInt32 *_retval)
|
||||
nsJAR::Init(nsFileSpec& zipFile)
|
||||
{
|
||||
*_retval = mZip.OpenArchive(aZipFileName);
|
||||
mZipFile = zipFile;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJAR::Extract(const char *aFilename, const char *aOutname, PRInt32 *_retval)
|
||||
nsJAR::Open()
|
||||
{
|
||||
*_retval = mZip.ExtractFile(aFilename, aOutname);
|
||||
const char* path = mZipFile.GetNativePathCString();
|
||||
PRInt32 err = mZip.OpenArchive(path);
|
||||
return ziperr2nsresult(err);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJAR::Close()
|
||||
{
|
||||
PRInt32 err = mZip.CloseArchive();
|
||||
return ziperr2nsresult(err);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJAR::Extract(const char *zipEntry, nsFileSpec& outFile)
|
||||
{
|
||||
const char* path = outFile.GetNativePathCString();
|
||||
PRInt32 err = mZip.ExtractFile(zipEntry, path);
|
||||
return ziperr2nsresult(err);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJAR::GetEntry(const char *zipEntry, nsIZipEntry* *result)
|
||||
{
|
||||
nsZipItem item;
|
||||
PRInt32 err = mZip.GetItem(zipEntry, &item);
|
||||
|
||||
nsJARItem* jarItem = new nsJARItem();
|
||||
if (jarItem == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
err = jarItem->Init(&item);
|
||||
if (err != ZIP_OK) {
|
||||
delete jarItem;
|
||||
return ziperr2nsresult(err);
|
||||
}
|
||||
|
||||
NS_ADDREF(jarItem);
|
||||
*result = jarItem;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJAR::Find(const char *aPattern, nsISimpleEnumerator **_retval)
|
||||
nsJAR::FindEntries(const char *aPattern, nsISimpleEnumerator **_retval)
|
||||
{
|
||||
if (!_retval)
|
||||
return NS_ERROR_INVALID_POINTER;
|
||||
if (!_retval)
|
||||
return NS_ERROR_INVALID_POINTER;
|
||||
|
||||
nsZipFind *find = mZip.FindInit(aPattern);
|
||||
if (!find)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
nsZipFind *find = mZip.FindInit(aPattern);
|
||||
if (!find)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsISimpleEnumerator *zipEnum = new nsJAREnumerator(find);
|
||||
if (!zipEnum)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF( zipEnum );
|
||||
nsISimpleEnumerator *zipEnum = new nsJAREnumerator(find);
|
||||
if (!zipEnum)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF( zipEnum );
|
||||
|
||||
*_retval = zipEnum;
|
||||
return NS_OK;
|
||||
*_retval = zipEnum;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -101,8 +180,6 @@ nsJAR::GetInputStream(const char *aFilename, nsIInputStream **_retval)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------
|
||||
// nsJAREnumerator constructor and destructor
|
||||
//----------------------------------------------
|
||||
|
@ -176,10 +253,15 @@ nsJAREnumerator::GetNext(nsISupports** aResult)
|
|||
}
|
||||
|
||||
// pack into an nsIJARItem
|
||||
nsIJARItem* jarItem = new nsJARItem(mCurr);
|
||||
nsJARItem* jarItem = new nsJARItem();
|
||||
if(jarItem)
|
||||
{
|
||||
jarItem->AddRef();
|
||||
PRInt32 err = jarItem->Init(mCurr);
|
||||
if (err != ZIP_OK) {
|
||||
delete jarItem;
|
||||
return err;
|
||||
}
|
||||
NS_ADDREF(jarItem);
|
||||
*aResult = jarItem;
|
||||
mIsCurrStale = PR_TRUE; // we just gave this one away
|
||||
return NS_OK;
|
||||
|
@ -195,30 +277,15 @@ nsJAREnumerator::GetNext(nsISupports** aResult)
|
|||
// nsJARItem constructors and destructor
|
||||
//-------------------------------------------------
|
||||
nsJARItem::nsJARItem()
|
||||
{
|
||||
}
|
||||
|
||||
nsJARItem::nsJARItem(nsZipItem* aOther)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
name = PL_strndup( aOther->name, aOther->namelen );
|
||||
namelen = aOther->namelen;
|
||||
|
||||
offset = aOther->offset;
|
||||
headerloc = aOther->headerloc;
|
||||
compression = aOther->compression;
|
||||
size = aOther->size;
|
||||
realsize = aOther->realsize;
|
||||
crc32 = aOther->crc32;
|
||||
|
||||
next = nsnull; // unused by a JARItem
|
||||
}
|
||||
|
||||
nsJARItem::~nsJARItem()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsJARItem, nsIJARItem::GetIID());
|
||||
NS_IMPL_ISUPPORTS1(nsJARItem, nsIZipEntry);
|
||||
|
||||
//------------------------------------------
|
||||
// nsJARItem::GetName
|
||||
|
@ -275,7 +342,7 @@ nsJARItem::GetSize(PRUint32 *aSize)
|
|||
// nsJARItem::GetRealSize
|
||||
//------------------------------------------
|
||||
NS_IMETHODIMP
|
||||
nsJARItem::GetRealsize(PRUint32 *aRealsize)
|
||||
nsJARItem::GetRealSize(PRUint32 *aRealsize)
|
||||
{
|
||||
if (!aRealsize)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
@ -290,7 +357,7 @@ nsJARItem::GetRealsize(PRUint32 *aRealsize)
|
|||
// nsJARItem::GetCrc32
|
||||
//------------------------------------------
|
||||
NS_IMETHODIMP
|
||||
nsJARItem::GetCrc32(PRUint32 *aCrc32)
|
||||
nsJARItem::GetCRC32(PRUint32 *aCrc32)
|
||||
{
|
||||
if (!aCrc32)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
|
|
@ -28,8 +28,8 @@
|
|||
#ifndef nsJAR_h__
|
||||
#define nsJAR_h__
|
||||
|
||||
#include "nsIZipReader.h"
|
||||
#include "prtypes.h"
|
||||
#include "nsIJAR.h"
|
||||
#include "nsIEnumerator.h"
|
||||
#include "nsZipArchive.h"
|
||||
#include "zipfile.h"
|
||||
|
@ -44,22 +44,23 @@ class nsIInputStream;
|
|||
* This class allows nsZipArchive to remain non-XPCOM yet still be loadable
|
||||
* by Mozilla.
|
||||
*------------------------------------------------------------------------*/
|
||||
class nsJAR : public nsIJAR
|
||||
class nsJAR : public nsIZipReader
|
||||
{
|
||||
public:
|
||||
|
||||
nsJAR();
|
||||
virtual ~nsJAR();
|
||||
|
||||
NS_DEFINE_STATIC_CID_ACCESSOR( NS_JAR_CID );
|
||||
NS_DEFINE_STATIC_CID_ACCESSOR( NS_ZIPREADER_CID );
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_DECL_NSIZIP
|
||||
NS_DECL_NSIZIPREADER
|
||||
|
||||
private:
|
||||
|
||||
nsZipArchive mZip;
|
||||
nsFileSpec mZipFile;
|
||||
nsZipArchive mZip;
|
||||
};
|
||||
|
||||
|
||||
|
@ -71,16 +72,12 @@ class nsJAR : public nsIJAR
|
|||
* An individual JAR entry. A set of nsJARItems macthing a
|
||||
* supplied pattern are returned in a nsJAREnumerator.
|
||||
*/
|
||||
class nsJARItem : public nsZipItem, public nsIJARItem
|
||||
class nsJARItem : public nsZipItem, public nsIZipEntry
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIZIPENTRY
|
||||
|
||||
//NS_DEFINE_STATIC_CID_ACCESSOR( NS_JARITEM_CID );
|
||||
|
||||
NS_DECL_NSIJARITEM
|
||||
|
||||
nsJARItem(nsZipItem* aOther);
|
||||
nsJARItem();
|
||||
virtual ~nsJARItem();
|
||||
};
|
||||
|
@ -98,12 +95,7 @@ class nsJAREnumerator : public nsISimpleEnumerator
|
|||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
//NS_DEFINE_STATIC_CID_ACCESSOR( NS_JARENUMERATOR_CID );
|
||||
|
||||
// nsISimpleEnumerator methods
|
||||
NS_IMETHOD HasMoreElements(PRBool* aResult);
|
||||
NS_IMETHOD GetNext(nsISupports** aResult);
|
||||
NS_DECL_NSISIMPLEENUMERATOR
|
||||
|
||||
nsJAREnumerator(nsZipFind *aFind);
|
||||
virtual ~nsJAREnumerator();
|
||||
|
|
|
@ -17,12 +17,11 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsNeckoUtil.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIFileSpec.h"
|
||||
#include "nsSpecialSystemDirectory.h"
|
||||
#include "nsJARDownloadListener.h"
|
||||
#include "nsJARChannel.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIFileTransportService.h"
|
||||
|
@ -31,7 +30,7 @@
|
|||
|
||||
static NS_DEFINE_CID(kFileTransportServiceCID, NS_FILETRANSPORTSERVICE_CID);
|
||||
static NS_DEFINE_CID(kMIMEServiceCID, NS_MIMESERVICE_CID);
|
||||
static NS_DEFINE_CID(kJARCID, NS_JAR_CID);
|
||||
static NS_DEFINE_CID(kZipReaderCID, NS_ZIPREADER_CID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -456,25 +455,29 @@ NS_IMETHODIMP
|
|||
nsJARChannel::Open(char* *contentType, PRInt32 *contentLength)
|
||||
{
|
||||
nsresult rv;
|
||||
rv = nsComponentManager::CreateInstance(kJARCID,
|
||||
nsnull,
|
||||
NS_GET_IID(nsIJAR),
|
||||
getter_AddRefs(mJAR));
|
||||
rv = nsComponentManager::CreateInstance(kZipReaderCID,
|
||||
nsnull,
|
||||
NS_GET_IID(nsIZipReader),
|
||||
getter_AddRefs(mJAR));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
char* path;
|
||||
rv = mJARBaseFile->GetNativePath(&path);
|
||||
nsFileSpec fs;
|
||||
rv = mJARBaseFile->GetFileSpec(&fs);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = mJAR->Init(fs);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = mJAR->Open();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIZipEntry> entry;
|
||||
rv = mJAR->GetEntry(mJAREntry, getter_AddRefs(entry));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PRInt32 retVal;
|
||||
rv = mJAR->Open(path, &retVal); // XXX this retVal sucks! -- fix nsIJAR interface
|
||||
nsCRT::free(path);
|
||||
if (NS_FAILED(rv) || retVal) return rv;
|
||||
|
||||
rv = mJAR->ItemSize(mJAREntry, (PRUint32*)&mContentLength);
|
||||
rv = entry->GetRealSize((PRUint32*)contentLength);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
*contentLength = mContentLength;
|
||||
return GetContentType(contentType);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,10 +26,10 @@
|
|||
#include "nsIJARChannel.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIJARProtocolHandler.h"
|
||||
#include "nsJARDownloadListener.h"
|
||||
#include "nsIJARURI.h"
|
||||
#include "nsIFileSystem.h"
|
||||
#include "nsIFileChannel.h"
|
||||
#include "nsIJAR.h"
|
||||
#include "nsIZipReader.h"
|
||||
#include "nsIFileChannel.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
|
@ -90,7 +90,7 @@ protected:
|
|||
nsCOMPtr<nsIURI> mJARBaseURI;
|
||||
nsCOMPtr<nsIFileChannel> mJARBaseFile;
|
||||
char* mJAREntry;
|
||||
nsCOMPtr<nsIJAR> mJAR;
|
||||
nsCOMPtr<nsIZipReader> mJAR;
|
||||
};
|
||||
|
||||
#endif // nsJARChannel_h__
|
||||
|
|
|
@ -53,12 +53,8 @@ static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
|
|||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
|
||||
static NS_DEFINE_IID(kIJAR_IID, NS_IJAR_IID);
|
||||
static NS_DEFINE_IID(kJAR_CID, NS_JAR_CID);
|
||||
|
||||
static NS_DEFINE_IID(kIJARFactory_IID, NS_IJARFactory_IID);
|
||||
static NS_DEFINE_IID(kJARFactory_CID, NS_JARFactory_CID);
|
||||
|
||||
static NS_DEFINE_IID(kIZipReaderIID, NS_IZIPREADER_IID);
|
||||
static NS_DEFINE_IID(kZipReaderCID, NS_ZIPREADER_CID);
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
@ -151,7 +147,7 @@ nsJARModule::GetClassObject(nsIComponentManager *aCompMgr,
|
|||
// Choose the appropriate factory, based on the desired instance
|
||||
// class type (aClass).
|
||||
nsCOMPtr<nsIGenericFactory> fact;
|
||||
if (aClass.Equals(kJAR_CID)) {
|
||||
if (aClass.Equals(kZipReaderCID)) {
|
||||
if (!mFactory) {
|
||||
// Create and save away the factory object for creating
|
||||
// new instances of JAR. This way if we are called
|
||||
|
@ -188,7 +184,7 @@ struct Components {
|
|||
|
||||
// The list of components we register
|
||||
static Components gComponents[] = {
|
||||
{ "LibJAR Component", &kJAR_CID,
|
||||
{ "Zip Reader", &kZipReaderCID,
|
||||
"component://netscape/libjar", },
|
||||
};
|
||||
#define NUM_COMPONENTS (sizeof(gComponents) / sizeof(gComponents[0]))
|
||||
|
|
|
@ -29,16 +29,6 @@
|
|||
#include "nsIURL.h"
|
||||
#include "nsJARChannel.h"
|
||||
|
||||
//temp vars
|
||||
/**
|
||||
#include "nsIZip.h"
|
||||
#include "nsIJAR.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIMIMEService.h"
|
||||
#define DEFAULT_TYPE "text/html"
|
||||
static NS_DEFINE_CID(kMIMEServiceCID, NS_MIMESERVICE_CID);
|
||||
static NS_DEFINE_CID(kJARCID, NS_JAR_CID);
|
||||
**/
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
static NS_DEFINE_CID(kJARUriCID, NS_JARURI_CID);
|
||||
|
||||
|
|
|
@ -17,12 +17,12 @@
|
|||
*/
|
||||
|
||||
#include "nsJARURI.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsNeckoUtil.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIJAR.h"
|
||||
#include "nsIZipReader.h"
|
||||
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
|
||||
|
|
|
@ -289,6 +289,54 @@ PRInt32 nsZipArchive::OpenArchive( const char * aArchiveName )
|
|||
return BuildFileList();
|
||||
}
|
||||
|
||||
//---------------------------------------------
|
||||
// nsZipArchive::CloseArchive
|
||||
//---------------------------------------------
|
||||
PRInt32 nsZipArchive::CloseArchive()
|
||||
{
|
||||
// close the file if open
|
||||
if ( mFd != 0 ) {
|
||||
PR_Close(mFd);
|
||||
}
|
||||
|
||||
// delete nsZipItems in table
|
||||
nsZipItem* pItem;
|
||||
for ( int i = 0; i < ZIP_TABSIZE; ++i)
|
||||
{
|
||||
pItem = mFiles[i];
|
||||
while ( pItem != 0 )
|
||||
{
|
||||
mFiles[i] = pItem->next;
|
||||
delete pItem;
|
||||
pItem = mFiles[i];
|
||||
}
|
||||
}
|
||||
return ZIP_OK;
|
||||
}
|
||||
|
||||
//---------------------------------------------
|
||||
// nsZipArchive::ItemSize
|
||||
//---------------------------------------------
|
||||
PRInt32 nsZipArchive::GetItem( const char * aFilename, nsZipItem *result)
|
||||
{
|
||||
//-- Parameter validity check
|
||||
if (aFilename == 0)
|
||||
return ZIP_ERR_PARAM;
|
||||
|
||||
//PRInt32 result;
|
||||
nsZipItem* aItem;
|
||||
|
||||
//-- find file information
|
||||
aItem = GetFileItem( aFilename );
|
||||
if ( aItem == 0 )
|
||||
{
|
||||
return ZIP_ERR_FNF;
|
||||
}
|
||||
|
||||
memcpy(result, &aItem, sizeof(aItem)); // copy struct
|
||||
return ZIP_OK;
|
||||
}
|
||||
|
||||
//---------------------------------------------
|
||||
// nsZipArchive::ReadInit
|
||||
//---------------------------------------------
|
||||
|
@ -1145,23 +1193,7 @@ nsZipArchive::nsZipArchive()
|
|||
|
||||
nsZipArchive::~nsZipArchive()
|
||||
{
|
||||
// close the file if open
|
||||
if ( mFd != 0 ) {
|
||||
PR_Close(mFd);
|
||||
}
|
||||
|
||||
// delete nsZipItems in table
|
||||
nsZipItem* pItem;
|
||||
for ( int i = 0; i < ZIP_TABSIZE; ++i)
|
||||
{
|
||||
pItem = mFiles[i];
|
||||
while ( pItem != 0 )
|
||||
{
|
||||
mFiles[i] = pItem->next;
|
||||
delete pItem;
|
||||
pItem = mFiles[i];
|
||||
}
|
||||
}
|
||||
(void)CloseArchive();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1179,6 +1211,28 @@ nsZipItem::~nsZipItem()
|
|||
delete [] name;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsZipItem::Init(nsZipItem* other)
|
||||
{
|
||||
if (name) delete[] name;
|
||||
name = (char*)PR_Malloc(other->namelen);
|
||||
if (name == 0)
|
||||
return ZIP_ERR_MEMORY;
|
||||
memcpy(name, other->name, other->namelen);
|
||||
|
||||
namelen = other->namelen;
|
||||
offset = other->offset;
|
||||
headerloc = other->headerloc;
|
||||
compression = other->compression;
|
||||
size = other->size;
|
||||
realsize = other->realsize;
|
||||
crc32 = other->crc32;
|
||||
mode = other->mode;
|
||||
next = 0; // don't copy next
|
||||
|
||||
return ZIP_OK;
|
||||
}
|
||||
|
||||
//------------------------------------------
|
||||
// nsZipRead constructor and destructor
|
||||
//------------------------------------------
|
||||
|
@ -1226,8 +1280,6 @@ nsZipArchive* nsZipFind::GetArchive()
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//------------------------------------------
|
||||
// helper functions
|
||||
//------------------------------------------
|
||||
|
|
|
@ -62,6 +62,8 @@ public:
|
|||
nsZipItem();
|
||||
~nsZipItem();
|
||||
|
||||
PRInt32 Init(nsZipItem* other);
|
||||
|
||||
private:
|
||||
//-- prevent copies and assignments
|
||||
nsZipItem& operator=(const nsZipItem& rhs);
|
||||
|
@ -99,7 +101,20 @@ public:
|
|||
* @return status code
|
||||
*/
|
||||
PRInt32 OpenArchive( const char * aArchiveName );
|
||||
|
||||
|
||||
/**
|
||||
* Closes an open archive.
|
||||
*/
|
||||
PRInt32 CloseArchive();
|
||||
|
||||
/**
|
||||
* GetItem
|
||||
*
|
||||
* @param aFilename Name of file in the archive
|
||||
* @return status code
|
||||
*/
|
||||
PRInt32 GetItem(const char * aFilename, nsZipItem *result);
|
||||
|
||||
/**
|
||||
* ReadInit
|
||||
*
|
||||
|
|
|
@ -157,6 +157,26 @@ interface nsIIOService : nsISupports
|
|||
in nsIInputStream inStr,
|
||||
in nsILoadGroup group,
|
||||
in nsIURI originalURI);
|
||||
|
||||
/**
|
||||
* Utility for protocol implementors -- extracts the scheme from a URL
|
||||
* string, consistently and according to spec.
|
||||
* @param urlString - the URL string to parse
|
||||
* @param schemeStartPos - the resulting starting position of the scheme substring
|
||||
* (may skip over whitespace)
|
||||
* @param schemeEndPos - the resulting ending position of the scheme substring
|
||||
* (the position of the colon)
|
||||
* @param scheme - an allocated substring containing the scheme. If this parameter
|
||||
* is null going into the routine, then the scheme is not allocated and
|
||||
* returned. Free with nsCRT::free.
|
||||
*
|
||||
* @return NS_OK - if successful
|
||||
* @return NS_ERROR_MALFORMED_URI - if the urlString is not of the right form
|
||||
*/
|
||||
void extractScheme(in string urlString,
|
||||
out unsigned long schemeStartPos,
|
||||
out unsigned long schemeEndPos,
|
||||
out string scheme);
|
||||
};
|
||||
|
||||
%{C++
|
||||
|
|
|
@ -138,27 +138,41 @@ nsIOService::GetProtocolHandler(const char* scheme, nsIProtocolHandler* *result)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
static nsresult
|
||||
GetScheme(const char* inURI, char* *scheme)
|
||||
NS_IMETHODIMP
|
||||
nsIOService::ExtractScheme(const char* inURI, PRUint32 *startPos, PRUint32 *endPos,
|
||||
char* *scheme)
|
||||
{
|
||||
// search for something up to a colon, and call it the scheme
|
||||
NS_ASSERTION(inURI, "null pointer");
|
||||
if (!inURI) return NS_ERROR_NULL_POINTER;
|
||||
char c;
|
||||
const char* URI = inURI;
|
||||
PRUint8 length = 0;
|
||||
// skip leading white space
|
||||
while (nsString::IsSpace(*URI))
|
||||
URI++;
|
||||
while ((c = *URI++) != '\0') {
|
||||
if (c == ':') {
|
||||
char* newScheme = (char *)PR_Malloc(length+1);
|
||||
if (newScheme == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsCRT::memcpy(newScheme, inURI, length);
|
||||
newScheme[length] = '\0';
|
||||
*scheme = newScheme;
|
||||
const char* uri = inURI;
|
||||
|
||||
// skip leading white space
|
||||
while (nsString::IsSpace(*uri))
|
||||
uri++;
|
||||
|
||||
PRUint32 start = uri - inURI;
|
||||
if (startPos) {
|
||||
*startPos = start;
|
||||
}
|
||||
|
||||
PRUint32 length = 0;
|
||||
char c;
|
||||
while ((c = *uri++) != '\0') {
|
||||
if (c == ':') {
|
||||
if (endPos) {
|
||||
*endPos = start + length + 1;
|
||||
}
|
||||
|
||||
if (scheme) {
|
||||
char* str = (char*)nsAllocator::Alloc(length + 1);
|
||||
if (str == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
nsCRT::memcpy(str, &inURI[start], length);
|
||||
str[length] = '\0';
|
||||
*scheme = str;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
else if (nsString::IsAlpha(c)) {
|
||||
|
@ -177,7 +191,7 @@ nsIOService::NewURI(const char* aSpec, nsIURI* aBaseURI,
|
|||
nsresult rv;
|
||||
nsIURI* base;
|
||||
char* scheme;
|
||||
rv = GetScheme(aSpec, &scheme);
|
||||
rv = ExtractScheme(aSpec, nsnull, nsnull, &scheme);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// then aSpec is absolute
|
||||
// ignore aBaseURI in this case
|
||||
|
|
|
@ -23,6 +23,11 @@
|
|||
#include "nsIChannel.idl"
|
||||
|
||||
interface nsISimpleEnumerator;
|
||||
native nsFileSpec(nsFileSpec);
|
||||
|
||||
%{C++
|
||||
#include "nsFileSpec.h"
|
||||
%}
|
||||
|
||||
[scriptable, uuid(73025830-0ce2-11d3-9331-00104ba0fd40)]
|
||||
interface nsIFileChannel : nsIChannel
|
||||
|
@ -117,5 +122,10 @@ interface nsIFileChannel : nsIChannel
|
|||
* the Query portion of the URI is used as the argument string.
|
||||
*/
|
||||
void Execute(in string args);
|
||||
|
||||
/**
|
||||
* XXX Until we eliminate nsFileSpec...
|
||||
*/
|
||||
[noscript] void GetFileSpec(out nsFileSpec spec);
|
||||
};
|
||||
|
||||
|
|
|
@ -721,6 +721,13 @@ nsFileChannel::Execute(const char *args)
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileChannel::GetFileSpec(nsFileSpec *spec)
|
||||
{
|
||||
*spec = mSpec;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -17,12 +17,11 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsNeckoUtil.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIFileSpec.h"
|
||||
#include "nsSpecialSystemDirectory.h"
|
||||
#include "nsJARDownloadListener.h"
|
||||
#include "nsJARChannel.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIFileTransportService.h"
|
||||
|
@ -31,7 +30,7 @@
|
|||
|
||||
static NS_DEFINE_CID(kFileTransportServiceCID, NS_FILETRANSPORTSERVICE_CID);
|
||||
static NS_DEFINE_CID(kMIMEServiceCID, NS_MIMESERVICE_CID);
|
||||
static NS_DEFINE_CID(kJARCID, NS_JAR_CID);
|
||||
static NS_DEFINE_CID(kZipReaderCID, NS_ZIPREADER_CID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -456,25 +455,29 @@ NS_IMETHODIMP
|
|||
nsJARChannel::Open(char* *contentType, PRInt32 *contentLength)
|
||||
{
|
||||
nsresult rv;
|
||||
rv = nsComponentManager::CreateInstance(kJARCID,
|
||||
nsnull,
|
||||
NS_GET_IID(nsIJAR),
|
||||
getter_AddRefs(mJAR));
|
||||
rv = nsComponentManager::CreateInstance(kZipReaderCID,
|
||||
nsnull,
|
||||
NS_GET_IID(nsIZipReader),
|
||||
getter_AddRefs(mJAR));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
char* path;
|
||||
rv = mJARBaseFile->GetNativePath(&path);
|
||||
nsFileSpec fs;
|
||||
rv = mJARBaseFile->GetFileSpec(&fs);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = mJAR->Init(fs);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = mJAR->Open();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIZipEntry> entry;
|
||||
rv = mJAR->GetEntry(mJAREntry, getter_AddRefs(entry));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PRInt32 retVal;
|
||||
rv = mJAR->Open(path, &retVal); // XXX this retVal sucks! -- fix nsIJAR interface
|
||||
nsCRT::free(path);
|
||||
if (NS_FAILED(rv) || retVal) return rv;
|
||||
|
||||
rv = mJAR->ItemSize(mJAREntry, (PRUint32*)&mContentLength);
|
||||
rv = entry->GetRealSize((PRUint32*)contentLength);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
*contentLength = mContentLength;
|
||||
return GetContentType(contentType);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,10 +26,10 @@
|
|||
#include "nsIJARChannel.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIJARProtocolHandler.h"
|
||||
#include "nsJARDownloadListener.h"
|
||||
#include "nsIJARURI.h"
|
||||
#include "nsIFileSystem.h"
|
||||
#include "nsIFileChannel.h"
|
||||
#include "nsIJAR.h"
|
||||
#include "nsIZipReader.h"
|
||||
#include "nsIFileChannel.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
|
@ -90,7 +90,7 @@ protected:
|
|||
nsCOMPtr<nsIURI> mJARBaseURI;
|
||||
nsCOMPtr<nsIFileChannel> mJARBaseFile;
|
||||
char* mJAREntry;
|
||||
nsCOMPtr<nsIJAR> mJAR;
|
||||
nsCOMPtr<nsIZipReader> mJAR;
|
||||
};
|
||||
|
||||
#endif // nsJARChannel_h__
|
||||
|
|
|
@ -29,16 +29,6 @@
|
|||
#include "nsIURL.h"
|
||||
#include "nsJARChannel.h"
|
||||
|
||||
//temp vars
|
||||
/**
|
||||
#include "nsIZip.h"
|
||||
#include "nsIJAR.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIMIMEService.h"
|
||||
#define DEFAULT_TYPE "text/html"
|
||||
static NS_DEFINE_CID(kMIMEServiceCID, NS_MIMESERVICE_CID);
|
||||
static NS_DEFINE_CID(kJARCID, NS_JAR_CID);
|
||||
**/
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
static NS_DEFINE_CID(kJARUriCID, NS_JARURI_CID);
|
||||
|
||||
|
|
|
@ -17,12 +17,12 @@
|
|||
*/
|
||||
|
||||
#include "nsJARURI.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsNeckoUtil.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIJAR.h"
|
||||
#include "nsIZipReader.h"
|
||||
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
|
||||
|
|
|
@ -117,8 +117,8 @@ nsInstallInfo::GetLocalFile(char **aPath)
|
|||
static NS_DEFINE_IID(kISoftwareUpdateIID, NS_ISOFTWAREUPDATE_IID);
|
||||
static NS_DEFINE_IID(kSoftwareUpdateCID, NS_SoftwareUpdate_CID);
|
||||
|
||||
static NS_DEFINE_IID(kIJARIID, NS_IJAR_IID);
|
||||
static NS_DEFINE_IID(kJARCID, NS_JAR_CID);
|
||||
static NS_DEFINE_IID(kIZipReaderIID, NS_IZIPREADER_IID);
|
||||
static NS_DEFINE_IID(kZipReaderCID, NS_ZIPREADER_CID);
|
||||
|
||||
nsInstall::nsInstall()
|
||||
{
|
||||
|
@ -143,7 +143,7 @@ nsInstall::nsInstall()
|
|||
mInstallArguments = "";
|
||||
|
||||
// mJarFileData is an opaque handle to the jarfile.
|
||||
nsresult rv = nsComponentManager::CreateInstance(kJARCID, nsnull, kIJARIID,
|
||||
nsresult rv = nsComponentManager::CreateInstance(kZipReaderCID, nsnull, kIZipReaderIID,
|
||||
(void**) &mJarFileData);
|
||||
|
||||
nsISoftwareUpdate *su;
|
||||
|
@ -2143,13 +2143,15 @@ nsInstall::Confirm(nsString& string, PRBool* aReturn)
|
|||
PRInt32
|
||||
nsInstall::OpenJARFile(void)
|
||||
{
|
||||
PRInt32 result;
|
||||
|
||||
nsresult rv = mJarFileData->Open( nsAutoCString(mJarFileLocation), &result );
|
||||
nsresult rv = mJarFileData->Init(nsFileSpec(mJarFileLocation));
|
||||
if (NS_FAILED(rv))
|
||||
return UNEXPECTED_ERROR;
|
||||
|
||||
return result;
|
||||
rv = mJarFileData->Open();
|
||||
if (NS_FAILED(rv))
|
||||
return UNEXPECTED_ERROR;
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -2207,7 +2209,7 @@ nsInstall::ExtractFileFromJar(const nsString& aJarfile, nsFileSpec* aSuggestedNa
|
|||
// We will overwrite what is in the way. is this something that we want to do?
|
||||
extractHereSpec->Delete(PR_FALSE);
|
||||
|
||||
nsresult rv = mJarFileData->Extract( nsAutoCString(aJarfile), nsNSPRPath( *extractHereSpec ), &result );
|
||||
nsresult rv = mJarFileData->Extract( nsAutoCString(aJarfile), *extractHereSpec );
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
if (extractHereSpec != nsnull)
|
||||
|
@ -2310,7 +2312,7 @@ nsInstall::ExtractDirEntries(const nsString& directory, nsVoidArray *paths)
|
|||
{
|
||||
char *buf;
|
||||
nsISimpleEnumerator *jarEnum = nsnull;
|
||||
nsIJARItem *currJARItem = nsnull;
|
||||
nsIZipEntry *currZipEntry = nsnull;
|
||||
|
||||
if ( paths )
|
||||
{
|
||||
|
@ -2318,7 +2320,7 @@ nsInstall::ExtractDirEntries(const nsString& directory, nsVoidArray *paths)
|
|||
pattern += "/*";
|
||||
PRInt32 prefix_length = directory.Length()+1; // account for slash
|
||||
|
||||
nsresult rv = mJarFileData->Find( nsAutoCString(pattern), &jarEnum );
|
||||
nsresult rv = mJarFileData->FindEntries( nsAutoCString(pattern), &jarEnum );
|
||||
if (NS_FAILED(rv) || !jarEnum)
|
||||
goto handle_err;
|
||||
|
||||
|
@ -2326,11 +2328,11 @@ nsInstall::ExtractDirEntries(const nsString& directory, nsVoidArray *paths)
|
|||
rv = jarEnum->HasMoreElements(&bMore);
|
||||
while (bMore && NS_SUCCEEDED(rv))
|
||||
{
|
||||
rv = jarEnum->GetNext( (nsISupports**) &currJARItem );
|
||||
if (currJARItem)
|
||||
rv = jarEnum->GetNext( (nsISupports**) &currZipEntry );
|
||||
if (currZipEntry)
|
||||
{
|
||||
// expensive 'buf' callee malloc per iteration!
|
||||
rv = currJARItem->GetName(&buf);
|
||||
rv = currZipEntry->GetName(&buf);
|
||||
if (NS_FAILED(rv))
|
||||
goto handle_err;
|
||||
if (buf)
|
||||
|
@ -2346,7 +2348,7 @@ nsInstall::ExtractDirEntries(const nsString& directory, nsVoidArray *paths)
|
|||
|
||||
PR_FREEIF( buf );
|
||||
}
|
||||
NS_IF_RELEASE(currJARItem);
|
||||
NS_IF_RELEASE(currZipEntry);
|
||||
}
|
||||
rv = jarEnum->HasMoreElements(&bMore);
|
||||
}
|
||||
|
@ -2357,7 +2359,7 @@ nsInstall::ExtractDirEntries(const nsString& directory, nsVoidArray *paths)
|
|||
|
||||
handle_err:
|
||||
NS_IF_RELEASE(jarEnum);
|
||||
NS_IF_RELEASE(currJARItem);
|
||||
NS_IF_RELEASE(currZipEntry);
|
||||
return EXTRACTION_FAILED;
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
#include "nsIComponentManager.h"
|
||||
#include "nsIProperties.h"
|
||||
#include "nsIEnumerator.h"
|
||||
#include "nsIJAR.h"
|
||||
#include "nsIZipReader.h"
|
||||
|
||||
class nsInstallInfo
|
||||
{
|
||||
|
@ -266,7 +266,7 @@ class nsInstall
|
|||
JSObject* mWinProfileObject;
|
||||
|
||||
nsString mJarFileLocation;
|
||||
nsIJAR* mJarFileData;
|
||||
nsIZipReader* mJarFileData;
|
||||
|
||||
nsString mInstallArguments;
|
||||
nsString mInstallURL;
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include "nsSoftwareUpdateIIDs.h"
|
||||
|
||||
#include "nsInstall.h"
|
||||
//#include "zipfile.h" // replaced by nsIJAR.h
|
||||
//#include "zipfile.h" // replaced by nsIZipReader.h
|
||||
|
||||
#include "nsRepository.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
@ -41,7 +41,8 @@
|
|||
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIEnumerator.h"
|
||||
#include "nsIJAR.h"
|
||||
#include "nsIZipReader.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
static NS_DEFINE_IID(kSoftwareUpdateCID, NS_SoftwareUpdate_CID);
|
||||
|
||||
|
@ -119,27 +120,26 @@ XPInstallErrorReporter(JSContext *cx, const char *message, JSErrorReport *report
|
|||
static PRInt32
|
||||
GetInstallScriptFromJarfile(const char* jarFile, char** scriptBuffer, PRUint32 *scriptLength)
|
||||
{
|
||||
nsIJAR* hZip = nsnull;
|
||||
nsCOMPtr<nsIZipReader> hZip;
|
||||
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);
|
||||
static NS_DEFINE_IID(kIZipReaderIID, NS_IZIPREADER_IID);
|
||||
static NS_DEFINE_IID(kZipReaderCID, NS_ZIPREADER_CID);
|
||||
nsresult rv = nsComponentManager::CreateInstance(kZipReaderCID, nsnull, kIZipReaderIID,
|
||||
getter_AddRefs(hZip));
|
||||
if (NS_FAILED(rv))
|
||||
return nsInstall::CANT_READ_ARCHIVE;
|
||||
}
|
||||
|
||||
rv = hZip->Init(nsFileSpec(jarFile));
|
||||
if (NS_FAILED(rv))
|
||||
return nsInstall::CANT_READ_ARCHIVE;
|
||||
|
||||
rv = hZip->Open();
|
||||
if (NS_FAILED(rv))
|
||||
return nsInstall::CANT_READ_ARCHIVE;
|
||||
|
||||
// Extract the install.js file to the temporary directory
|
||||
nsSpecialSystemDirectory installJSFileSpec(nsSpecialSystemDirectory::OS_TemporaryDirectory);
|
||||
|
@ -147,8 +147,8 @@ GetInstallScriptFromJarfile(const char* jarFile, char** scriptBuffer, PRUint32 *
|
|||
installJSFileSpec.MakeUnique();
|
||||
|
||||
// Extract the install.js file.
|
||||
rv = hZip->Extract( "install.js", nsNSPRPath(installJSFileSpec), &result );
|
||||
if ( NS_SUCCEEDED(rv) && result == 0 )
|
||||
rv = hZip->Extract("install.js", installJSFileSpec);
|
||||
if ( NS_SUCCEEDED(rv) )
|
||||
{
|
||||
// Read it into a buffer
|
||||
char* buffer;
|
||||
|
@ -190,8 +190,6 @@ GetInstallScriptFromJarfile(const char* jarFile, char** scriptBuffer, PRUint32 *
|
|||
result = nsInstall::NO_INSTALL_SCRIPT;
|
||||
}
|
||||
|
||||
NS_IF_RELEASE( hZip );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче