From fd334d93a25e6e1eecdc623049c456e7a2ad1c3e Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Wed, 12 Jan 2022 23:15:11 +0100 Subject: [PATCH] We're done for today --- src/archive.v | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/archive.v b/src/archive.v index 6846ddb..c6e253a 100644 --- a/src/archive.v +++ b/src/archive.v @@ -47,20 +47,22 @@ pub fn get_pkg_info(pkg_path string) ?string { C.archive_read_support_format_all(a) // TODO find out where does this 10240 come from + println('1') r = C.archive_read_open_filename(a, &char(pkg_path.str), 10240) if r != C.ARCHIVE_OK { return error('Failed to open package.') } + println('2') // 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 { // TODO possibly avoid this cstring_to_vstring if cstring_to_vstring(C.archive_entry_pathname(entry)) == '.PKGINFO' { size := C.archive_entry_size(entry) - mut buf := []byte{len: size} + buf = []byte{len: size} C.archive_read_data(a, voidptr(&buf), size) break }else{ @@ -69,5 +71,5 @@ pub fn get_pkg_info(pkg_path string) ?string { } r = C.archive_read_free(a) // Note 3 - return '' + return buf.bytestr() }