zip

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(aFilePath) : Map

Will list all files and folders of the loaded ZIP contents into a Map with name, size, compressedSize, comment, crc and time. Optionally you can provide a zip aFilePath instead of using the current in-memory zip.

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.streamCreate

ZIP.streamCreate(aFilePath)

Creates an empty ZIP file on aFilePath.

ZIP.streamCreateFolder

ZIP.streamCreateFolder(aFilePath, aFolder) : boolean

Creates aFolder on aFilePath ZIP file. Returns true if the folder was created or false if it already existed.

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, useTempFile)

Sets a aName file on the aFilePath ZIP provided with the aJavaInputStream provided. All missing directories will be created. Optionally you can specify if a temp file should be used instead of memory (useTempFile = true).  Additionally, for performance, you can provide an array of maps (composed of "n" name of file and "s" javaInputStream) instead of  aJavaInputStream (aName will be ignored in this case).

ZIP.streamRemoveFile

ZIP.streamRemoveFile(aFilePath, aName)

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

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.