Zip

com.phasmidsoftware.xmldoc.xml.Zip
object Zip

Utility for reading the contents of a zip archive (such as an IDML package) in memory, without extracting it to disk. This is deliberately format-agnostic: it knows nothing about IDML's internal structure, only how to list and read the entries of a zip file.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Zip.type

Members list

Value members

Concrete methods

def deleteEntry(file: File, entryName: String): Try[Unit]

Method to delete a specific entry from an existing zip file, in place - the write-side counterpart to writeEntry, using the same zip filesystem provider. A no-op (Success) if the entry doesn't exist, same as Files.deleteIfExists.

Method to delete a specific entry from an existing zip file, in place - the write-side counterpart to writeEntry, using the same zip filesystem provider. A no-op (Success) if the entry doesn't exist, same as Files.deleteIfExists.

Value parameters

entryName

the name of the entry to delete (e.g. "Spreads/Spread_ud1.xml").

file

the zip file (must already exist).

Attributes

Returns

a Try[Unit], Success whether or not the entry was actually present.

def entries(file: File): Try[Seq[String]]

Method to yield the names of all entries in the given zip file, in the order the zip file declares them.

Method to yield the names of all entries in the given zip file, in the order the zip file declares them.

Value parameters

file

the zip file.

Attributes

Returns

a Try of Seq[String] containing the entry names.

def readEntry(file: File, entryName: String): Try[String]

Method to read the content of a specific entry within a zip file, decoded as UTF-8 text.

Method to read the content of a specific entry within a zip file, decoded as UTF-8 text.

Value parameters

entryName

the name of the entry to read (e.g. "designmap.xml").

file

the zip file.

Attributes

Returns

a Try of String containing the entry's content.

def writeEntry(file: File, entryName: String, content: String): Try[Unit]

Method to write (creating or overwriting) the content of a specific entry within an existing zip file, encoded as UTF-8 text. Unlike readEntry, this does mutate file.

Method to write (creating or overwriting) the content of a specific entry within an existing zip file, encoded as UTF-8 text. Unlike readEntry, this does mutate file.

NOTE: java.util.zip.ZipFile is read-only, so this uses the JDK's zip filesystem provider instead, which supports updating a single entry in place without having to rewrite the rest of the archive.

Value parameters

content

the new content of the entry.

entryName

the name of the entry to write (e.g. "designmap.xml").

file

the zip file (must already exist).

Attributes

Returns

a Try[Unit], Success if the entry was written.