MCPcopy Create free account
hub / github.com/bodgit/sevenzip / extractFile

Function extractFile

reader_test.go:37–57  ·  view source on GitHub ↗
(tb testing.TB, r io.Reader, h hash.Hash, f *sevenzip.File)

Source from the content-addressed store, hash-verified

35var errCRCMismatch = errors.New("CRC doesn't match")
36
37func extractFile(tb testing.TB, r io.Reader, h hash.Hash, f *sevenzip.File) error {
38 tb.Helper()
39
40 h.Reset()
41
42 if _, err := io.Copy(h, r); err != nil {
43 return fmt.Errorf("error extracting file: %w", err)
44 }
45
46 if f.UncompressedSize > 0 && f.CRC32 == 0 {
47 tb.Log("archive member", f.Name, "has no CRC")
48
49 return nil
50 }
51
52 if !util.CRC32Equal(h.Sum(nil), f.CRC32) {
53 return errCRCMismatch
54 }
55
56 return nil
57}
58
59//nolint:lll
60func extractArchive(tb testing.TB, r *sevenzip.Reader, stream int, h hash.Hash, fn func(io.Reader) io.Reader, optimised bool) (err error) {

Callers 2

extractArchiveFunction · 0.85

Calls 1

CRC32EqualFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…