Close this zip file for reading and writing. If this zip file is reading or writing a stream, then the underlying stream is also closed. This method is guaranteed to never throw an IOErr. Return true if the close was successful or false if an error occurred.
Return a negative integer, zero, or a positive integer if this object is less than, equal to, or greater than the specified object:
this < that => <0
this == that => 0
this > that => >0
This method may also be accessed via the <
<=
<=>
>=
and >
shortcut operators. If not overridden the default
implementation compares the toStr
representations. Also see docLang.
Examples:
3.compare(8) => -1
8.compare(3) => 1
8.compare(8) => 0
3 <=> 8 => -1 // shortcut for 3.compare(8)
Compare this object to the specified for equality. This
method may be accessed via the == and != shortcut operators.
If not overridden the default implementation compares for
reference equality using the === operator. If this method
is overridden, then hash() must also be overridden such that
any two objects which return true for equals() must return
the same value for hash(). This method must accept null
and
return false.
Get the underlying file or null if using streams.
Finish writing the contents of this zip file, but leave the underlying OutStream open. This method is guaranteed to never throw an IOErr. Return true if the stream was finished successfully or false if an error occurred. Throw UnsupportedErr if zip is not writing to an output stream.
Return a unique hashcode for this object. If a class overrides hash() then it must ensure if equals() returns true for any two objects then they have same hash code.
Call the specified function for every entry in the zip. Use the File's input stream to read the file contents. Some file meta-data such as size may not be available. Throw UnsupportedErr if not reading from an input stream.
Read the next entry in the zip. Use the File's input stream to read the file contents. Some file meta-data such as size may not be available. Return null if at end of zip file. Throw UnsupportedErr if not reading from an input stream.
Get an immutable representation of this instance or throw NotImmutableErr if this object cannot be represented as an immutable:
If file is not null then return file.toStr, otherwise return a suitable string representation.
Trap a dynamic call for handling. Dynamic calls are invoked with the -> shortcut operator:
a->x a.trap("x", null)
a->x() a.trap("x", null)
a->x = b a.trap("x", [b])
a->x(b) a.trap("x", [b])
a->x(b, c) a.trap("x", [b, c])
The default implementation provided by Obj attempts to use reflection. If name maps to a method, it is invoked with the specified arguments. If name maps to a field and args.size is zero, get the field. If name maps to a field and args.size is one, set the field and return args[0]. Otherwise throw UnknownSlotErr.
This method called whenever an it-block is applied to an
object. The default implementation calls the function with this
,
and then returns this
.
Append a new file to the end of this zip file and return an OutStream which may be used to write the file contents. The Uri must not contain a query or fragment; it may optionally start with a slash. Closing the OutStream will close only this file entry - use Zip.close() when finished writing the entire zip file. Throw UnsupportedErr if zip is not writing to an output stream.
Next entry options:
NOTE: setting level to 0 sets method to STORE, else to DEFLATED.
Examples:
out := zip.writeNext(`/docs/test.txt`)
out.writeLine("test")
out.close
Static
deflateStatic
deflateConstruct a new deflate output stream which wraps the given output stream, and compresses data using the "deflate" compression format. Options:
Static
echoWrite x.toStr
to standard output followed by newline. If x
is null then print "null". If no argument is provided then
print an empty line.
Optional
x: JsObjStatic
gzipStatic
gzipStatic
openStatic
readStatic
unzipStatic
write
Zip is used to read/write compressed zip files and streams. Zip may be used in three modes: