mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1034143: Step 2b: Add the ability to read jar files from arbitrary memory. r=honzab r=jduell
This commit is contained in:
parent
91e13251f6
commit
91254ac73f
@ -63,7 +63,7 @@ interface nsIZipEntry : nsISupports
|
||||
readonly attribute unsigned long permissions;
|
||||
};
|
||||
|
||||
[scriptable, uuid(894c8dc0-37c8-11e4-916c-0800200c9a66)]
|
||||
[scriptable, uuid(9ba4ef54-e0a0-4f65-9d23-128482448885)]
|
||||
interface nsIZipReader : nsISupports
|
||||
{
|
||||
/**
|
||||
@ -78,9 +78,19 @@ interface nsIZipReader : nsISupports
|
||||
*/
|
||||
void openInner(in nsIZipReader zipReader, in AUTF8String zipEntry);
|
||||
|
||||
/**
|
||||
* Opens a zip file stored in memory; the file attribute will be null.
|
||||
*
|
||||
* The ZipReader does not copy or take ownership of this memory; the
|
||||
* caller must ensure that it is valid and unmodified until the
|
||||
* ZipReader is closed or destroyed, and must free the memory as
|
||||
* appropriate afterwards.
|
||||
*/
|
||||
void openMemory(in voidPtr aData, in unsigned long aLength);
|
||||
|
||||
/**
|
||||
* The file that represents the zip with which this zip reader was
|
||||
* initialized.
|
||||
* initialized. This will be null if there is no underlying file.
|
||||
*/
|
||||
readonly attribute nsIFile file;
|
||||
|
||||
|
@ -171,6 +171,23 @@ nsJAR::OpenInner(nsIZipReader *aZipReader, const nsACString &aZipEntry)
|
||||
return mZip->OpenArchive(handle);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJAR::OpenMemory(void* aData, uint32_t aLength)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aData);
|
||||
if (mOpened) return NS_ERROR_FAILURE; // Already open!
|
||||
|
||||
mOpened = true;
|
||||
|
||||
nsRefPtr<nsZipHandle> handle;
|
||||
nsresult rv = nsZipHandle::Init(static_cast<uint8_t*>(aData), aLength,
|
||||
getter_AddRefs(handle));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
return mZip->OpenArchive(handle);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJAR::GetFile(nsIFile* *result)
|
||||
{
|
||||
|
@ -244,6 +244,17 @@ nsresult nsZipHandle::Init(nsZipArchive *zip, const char *entry,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsZipHandle::Init(const uint8_t* aData, uint32_t aLen,
|
||||
nsZipHandle **aRet)
|
||||
{
|
||||
nsRefPtr<nsZipHandle> handle = new nsZipHandle();
|
||||
|
||||
handle->mFileData = aData;
|
||||
handle->mLen = aLen;
|
||||
handle.forget(aRet);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
int64_t nsZipHandle::SizeOfMapping()
|
||||
{
|
||||
return mLen;
|
||||
|
@ -385,6 +385,8 @@ public:
|
||||
PRFileDesc **aFd = nullptr);
|
||||
static nsresult Init(nsZipArchive *zip, const char *entry,
|
||||
nsZipHandle **ret);
|
||||
static nsresult Init(const uint8_t* aData, uint32_t aLen,
|
||||
nsZipHandle **aRet);
|
||||
|
||||
NS_METHOD_(MozExternalRefCountType) AddRef(void);
|
||||
NS_METHOD_(MozExternalRefCountType) Release(void);
|
||||
|
Loading…
Reference in New Issue
Block a user