We're done for today

main
Jef Roosens 2022-01-12 23:15:11 +01:00
parent 6dbac5918b
commit fd334d93a2
Signed by: Jef Roosens
GPG Key ID: 955C0660072F691F
1 changed files with 5 additions and 3 deletions

View File

@ -47,20 +47,22 @@ pub fn get_pkg_info(pkg_path string) ?string {
C.archive_read_support_format_all(a) C.archive_read_support_format_all(a)
// TODO find out where does this 10240 come from // TODO find out where does this 10240 come from
println('1')
r = C.archive_read_open_filename(a, &char(pkg_path.str), 10240) r = C.archive_read_open_filename(a, &char(pkg_path.str), 10240)
if r != C.ARCHIVE_OK { if r != C.ARCHIVE_OK {
return error('Failed to open package.') return error('Failed to open package.')
} }
println('2')
// We iterate over every header in search of the .PKGINFO one // We iterate over every header in search of the .PKGINFO one
mut pkg_info := '' mut buf := []byte{}
for C.archive_read_next_header(a, &entry) == C.ARCHIVE_OK { for C.archive_read_next_header(a, &entry) == C.ARCHIVE_OK {
// TODO possibly avoid this cstring_to_vstring // TODO possibly avoid this cstring_to_vstring
if cstring_to_vstring(C.archive_entry_pathname(entry)) == '.PKGINFO' { if cstring_to_vstring(C.archive_entry_pathname(entry)) == '.PKGINFO' {
size := C.archive_entry_size(entry) size := C.archive_entry_size(entry)
mut buf := []byte{len: size} buf = []byte{len: size}
C.archive_read_data(a, voidptr(&buf), size) C.archive_read_data(a, voidptr(&buf), size)
break break
}else{ }else{
@ -69,5 +71,5 @@ pub fn get_pkg_info(pkg_path string) ?string {
} }
r = C.archive_read_free(a) // Note 3 r = C.archive_read_free(a) // Note 3
return '' return buf.bytestr()
} }