Bug 1258574 - Allow JARReader to read data already in memory; r=glandium

This will be needed to teach artifact builds to extract files from
omni.ja files whose content is loaded into memory (from a tar
archive).

MozReview-Commit-ID: LH2HkKx5Zj3

--HG--
extra : rebase_source : 7f6b176f0ef9fc87889151d1d02da62de8a455d8
extra : source : 266928b5a7615fa054c70adf0f649cbb3f085e8d
This commit is contained in:
Gregory Szorc 2016-03-21 16:36:22 -07:00
parent b19cc22cce
commit 79ad6e2449

View File

@ -332,14 +332,14 @@ class JarReader(object):
Class with methods to read Jar files. Can open standard jar files as well
as Mozilla jar files (see further details in the JarWriter documentation).
'''
def __init__(self, file=None, fileobj=None):
def __init__(self, file=None, fileobj=None, data=None):
'''
Opens the given file as a Jar archive. Use the given file-like object
if one is given instead of opening the given file name.
'''
if fileobj:
data = fileobj.read()
else:
elif file:
data = open(file, 'rb').read()
self._data = memoryview(data)
# The End of Central Directory Record has a variable size because of