Pony implementation of libzip
pony-libzip is "in-flight" software. It's getting there.
Using corral, into your deps it goes...
{
"locator": "github.com/redvers/pony-libzip.git",
"version": ""
}corral fetchto fetch your dependenciesuse "ponyzip"to include this packagecorral run -- ponycto compile your application
/* You need to select which flags to open your file with...
if we assume you just want to read a file, this is a
reasonable default */
let readflags: ZipFlags = ZipFlags.>set(ZipRDOnly).>set(ZipCheckcons)
/* Now we need to open the archive itself. */
let archive: PonyZip = PonyZip("test.zip", readflags)
/* We need to ensure that the file was opened correctly */
if (not archive.valid()) then
env.out.print("We have failed to open said file: " + archive.errorstr)
error
else
end.out.print("The zip file has been successfully opened */
end/* There are two basic ways to address files in an archive,
by name and by index. In this example we are going to
use the index. */
let count: USize = archive.count()
/* Now let's display each of the filenames in the archive */
for index in Range(0, count) do
/* The Zipstat is a struct that contains the basic info
for file inside the archive. */
let zipstat: Zipstat = archive.zip_stat_index(index)?
env.out.print("The filename at index: " + index.string() + " is: " + zipstat.name())
end/* You can extract the contents of a file like so: */
let zipstat0: Zipstat = archive.zip_stat_index(index)?
let data: Array[U8] val = archive.readfile(zipstat0)archive.close()Look at the ponyzip/_test.pony for more examples of usage. The test suite will likely be the most authoratitive info available.
Please feel free to open Issues and Pull Requests as needed.
Red