File
An open file within a ZIP archive.
Returned by Archive.open and
Entry.open. Entry metadata such as size and Unix mode
is available on Entry rather than here.
Methods
close()
Closes the file.
Example
open "archive.zip" do |archive|
let file = archive.open "data.txt"
let content = file.read 1024
file.close()
read size -> Bin
Reads data from the file. Read mode only.
Parameters
| Name | Type | Description |
|---|---|---|
size |
Int |
Maximum number of bytes to read. |
Errors
Raises a runtime error if called on a file opened in write mode.
Example
open "archive.zip" do |archive|
archive.open "document.txt" do |file|
let data = file.read 4096
echo "Read $(data.len) bytes"
echo $ Str $data
write data
Writes data to the file. Write mode only.
Parameters
| Name | Type | Description |
|---|---|---|
data |
(Bin | Str) |
Data to write. |
Errors
Raises a runtime error if called on a file opened in read mode.