Skip to content

Is there a reason for use archive/tar like API instead of archive/zip? #4

@ajnavarro

Description

@ajnavarro

First of all, congratulations and thanks for this library.

As far as I know, 7zip uses an index, like zip files.

Going through the code, we can see that we are loading all entries when we initialize the 7zip reader, so when we call Next(), we are just iterating through a slice to get the FileInfo:

go7z/reader.go

Lines 188 to 197 in 9c09b6b

func (sz *Reader) nextFileInfo() *headers.FileInfo {
var fileInfo *headers.FileInfo
if sz.fileIndex < len(sz.header.FilesInfo) {
fileInfo = sz.header.FilesInfo[sz.fileIndex]
sz.fileIndex++
return fileInfo
}
return nil
}

My question is, why do we need an iterator-like API if we know the entries beforehand? Maybe an archive/zip API would be better for this use case?:

zr, _ := go7z.NewReader(readerAt, size)
for _, f := range zr.Files {
    info := f.FileInfo()
    name := f.Name
    reader, _ := f.Open()
    ...
}

Sorry in advance if I missed some obvious problem here that makes this impossible. If you think it's a good idea, I'll be happy to help with the implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions