Fix extracting .folders
parent
7ec613a562
commit
a1d34d8b1d
|
@ -11,6 +11,8 @@ struct C.zip_t {
|
|||
|
||||
type Zip = C.zip_t
|
||||
|
||||
pub type Fn_on_extract_entry = fn (&&char, &&char) int
|
||||
|
||||
fn C.zip_open(&char, int, char) &Zip
|
||||
|
||||
fn C.zip_close(&Zip)
|
||||
|
@ -41,9 +43,13 @@ fn C.zip_entry_noallocread(&Zip, voidptr, usize) int
|
|||
|
||||
fn C.zip_entry_fread(&Zip, &char) int
|
||||
|
||||
fn C.zip_total_entries(&Zip) int
|
||||
fn C.zip_entries_total(&Zip) int
|
||||
|
||||
fn C.zip_extract_without_callback(&char, &char) int
|
||||
fn C.zip_extract(&char, &char, Fn_on_extract_entry, voidptr) int
|
||||
|
||||
fn cb_zip_extract(filename &&char, arg &&char) int {
|
||||
return 0
|
||||
}
|
||||
|
||||
// CompressionLevel lists compression levels, see in "thirdparty/zip/miniz.h"
|
||||
pub enum CompressionLevel {
|
||||
|
@ -230,7 +236,7 @@ pub fn extract_zip_to_dir(file string, dir string) ?bool {
|
|||
if C.access(&char(dir.str), 0) == -1 {
|
||||
return error('szip: cannot open directory for extracting, directory not exists')
|
||||
}
|
||||
res := C.zip_extract_without_callback(&char(file.str), &char(dir.str))
|
||||
res := C.zip_extract(&char(file.str), &char(dir.str), cb_zip_extract, 0)
|
||||
return res == 0
|
||||
}
|
||||
|
||||
|
@ -288,7 +294,7 @@ pub fn zip_folder(path_to_dir string, path_to_export_zip string) {
|
|||
|
||||
// total returns the number of all entries (files and directories) in the zip archive.
|
||||
pub fn (mut zentry Zip) total() ?int {
|
||||
tentry := int(C.zip_total_entries(zentry))
|
||||
tentry := int(C.zip_entries_total(zentry))
|
||||
if tentry == -1 {
|
||||
return error('szip: cannot count total entries')
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue