Archive
¶
mutool only
- new Archive(path)¶
Constructor method.
Create a new archive based either on a tar or zip file or the contents of a directory.
- Arguments:
path –
String
.
- Returns:
Archive
.
EXAMPLE
var archive = new mupdf.Archive("example1.zip"); var archive2 = new mupdf.Archive("example2.tar");
Instance methods
- getFormat()¶
Returns a string describing the archive format.
- Returns:
String
.
EXAMPLE
var archive = new mupdf.Archive("example1.zip"); print(archive.getFormat());
- countEntries()¶
Returns the number of entries in the archive.
- Returns:
Integer
.
EXAMPLE
var archive = new mupdf.Archive("example1.zip"); var numEntries = archive.countEntries();
- listEntry(idx)¶
Returns the name of entry number
idx
in the archive.- Arguments:
idx –
Integer
.
- Returns:
String
.
EXAMPLE
var archive = new mupdf.Archive("example1.zip"); var entry = archive.listEntry(0);
- hasEntry(name)¶
Returns true if an entry of the given name exists in the archive.
- Arguments:
name –
String
.
- Returns:
Boolean
.
EXAMPLE
var archive = new mupdf.Archive("example1.zip"); var hasEntry = archive.hasEntry("file1.txt");
- readEntry(name)¶
Returns the contents of the entry of the given name.
- Arguments:
name –
String
.
- Returns:
String
.
EXAMPLE
var archive = new mupdf.Archive("example1.zip"); var contents = archive.readEntry("file1.txt");
MultiArchive
¶
mutool only
- new MultiArchive()¶
Constructor method.
Create a new empty multi archive.
- Returns:
MultiArchive
.
EXAMPLE
var multiArchive = new mupdf.MultiArchive();
Instance methods
- mountArchive(subArchive, path)¶
Add an archive to the set of archives handled by a multi archive. If
path
isnull
, thesubArchive
contents appear at the top-level, otherwise they will appear prefixed by the stringpath
.- Arguments:
subArchive –
Archive
.path –
String
.
EXAMPLE
var archive = new mupdf.MultiArchive(); archive.mountArchive(new mupdf.Archive("example1.zip"), null); archive.mountArchive(new mupdf.Archive("example2.tar"), "subpath"); print(archive.hasEntry("file1.txt")); print(archive.hasEntry("subpath/file2.txt"));
Assuming that
example1.zip
contains afile1.txt
andexample2.tar
containsfile2.txt
, the multiarchive now allows access to “file1.txt” and “subpath/file2.txt”.
TreeArchive
¶
mutool only
- new TreeArchive()¶
Constructor method.
Create a new empty tree archive.
- Returns:
TreeArchive
.
EXAMPLE
var treeArchive = new mupdf.TreeArchive();
Instance methods
- add(name, buffer)¶
Add a named buffer to a tree archive.
- Arguments:
name –
String
.buffer –
Buffer
.
EXAMPLE
var buf = new mupdf.Buffer(); buf.writeLine("hello world!"); var archive = new mupdf.TreeArchive(); archive.add("file2.txt", buf); print(archive.hasEntry("file2.txt"));