Skip to content
Nuno Aguiar edited this page Dec 29, 2017 · 2 revisions

ZIP.ZIP

ZIP.ZIP(anArrayOfBytes) : ZIP

Creates a ZIP object instance. If anArrayOfBytes is provided it will read it as a ZIP compressed contents into the ZIP object.


ZIP.clean

ZIP.clean()

Will clean all internal data regarding any previously ZIP contents handled by this object.


ZIP.close

ZIP.close()

Will close the ZIP file associated with this object.


ZIP.generate

ZIP.generate(aMapOfOptions, dontReload) : anArrayOfBytes

Will generate a ZIP anArrayOfBytes contents (that can then by saved into a file) given the provided options (a map where you can specify the compressionLevel as a number). If dontReload = true then the internal ZIP object contents won't be reloaded after generating. Example:

plugin("ZIP");
var zip = new ZIP();
var text = new java.lang.String("Some example test to zip into a zip file");
var openaf = io.readFileBytes("c:\apps\OpenAF\openaf.jar");
zip.putFile("text.txt", text.getBytes());
zip.putFile("openaf.jar", openaf);
var newZip = zip.generate({"compressionLevel": 9});
var zip = new ZIP(newZip);
print(beautifier(zip.list()));


ZIP.generate2File

ZIP.generate2File(aFile, aMapOfOptions, dontReload) : anArrayOfBytes

Will generate a ZIP into aFile given the provided options (a map where you can specify the compressionLevel as a number). If dontReload = true then the internal ZIP object contents won't be reloaded after generating.


ZIP.getFile

ZIP.getFile(aFilename) : anArrayOfBytes

Will uncompress the corresponding aFilename from the ZIP contents into an arrays of bytes.


ZIP.gunzip

ZIP.gunzip(anArrayOfBytes) : anObject

Will gunzip/uncompress the provided anArrayOfBytes into the original anObject compressed with ZIP.gzip.


ZIP.gzip

ZIP.gzip(anObject) : ArrayOfBytes

Will gzip/compress the contents of the anObject into an array of bytes. To uncompress use ZIP.gunzip.


ZIP.list

ZIP.list() : Map

Will list all files and folders of the loaded ZIP contents into a Map with name, size, compressedSize, comment, crc and time.


ZIP.load

ZIP.load(anArrayOfBytes)

Loads anArrayOfBytes ZIP contents into the internal object structures.


ZIP.loadFile

ZIP.loadFile(aFilename)

Will load a ZIP file aFilename into the ZIP object internal structure.


ZIP.putFile

ZIP.putFile(aFilename, anArrayOfBytes)

Will add anArrayOfBytes to the ZIP contents as aFilename.


ZIP.remove

ZIP.remove(aFilename)

Will remove aFilename from the ZIP contents.


ZIP.streamGetFile

ZIP.streamGetFile(aFilePath, aName) : anArrayOfBytes

Retrieves aName file from aFilePath zip file without loading the zip file contents into memory returning the  file contents as an array of bytes.


ZIP.streamGetFileStream

ZIP.streamGetFileStream(aFilePath, aName) : JavaInputStream

Retrieves aName file from aFilePath zip file without loading the zip file contents into memory returning a  Java InputStream.


ZIP.streamPutFile

ZIP.streamPutFile(aFilePath, aName, anArrayOfBytes)

Sets a aName file on the aFilePath ZIP provided with the anArrayOfBytes provided. All missing directories will be created.


ZIP.streamPutFileStream

ZIP.streamPutFileStream(aFilePath, aName, aJavaInputStream)

Sets a aName file on the aFilePath ZIP provided with the aJavaInputStream provided. All missing directories will be created.


ZIP.streamRemoveFile

ZIP.streamRemoveFile(aFilePath, aName)

Removes a file/directory aName from the aFilePath ZIP file provided.

Clone this wiki locally