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

Function readSubStreamsInfo

types.go:487–569  ·  view source on GitHub ↗

nolint:cyclop,funlen,gocognit

(r util.Reader, folder []*folder)

Source from the content-addressed store, hash-verified

485
486//nolint:cyclop,funlen,gocognit
487func readSubStreamsInfo(r util.Reader, folder []*folder) (*subStreamsInfo, error) {
488 s := new(subStreamsInfo)
489
490 id, err := r.ReadByte()
491 if err != nil {
492 return nil, fmt.Errorf("readSubStreamsInfo: ReadByte error: %w", err)
493 }
494
495 s.streams = make([]uint64, len(folder))
496 if id == idNumUnpackStream {
497 for i := range s.streams {
498 if s.streams[i], err = readUint64(r); err != nil {
499 return nil, err
500 }
501 }
502
503 id, err = r.ReadByte()
504 if err != nil {
505 return nil, fmt.Errorf("readSubStreamsInfo: ReadByte error: %w", err)
506 }
507 } else {
508 for i := range s.streams {
509 s.streams[i] = 1
510 }
511 }
512
513 // Count the files in each stream
514 files := uint64(0)
515 for _, v := range s.streams {
516 files += v
517 }
518
519 if err := checkUint64(files, false); err != nil {
520 return nil, err
521 }
522
523 if id == idSize {
524 s.size = make([]uint64, files)
525 k := 0
526
527 for i := range s.streams {
528 if s.streams[i] == 0 {
529 continue
530 }
531
532 total := uint64(0)
533
534 for j := uint64(1); j < s.streams[i]; j++ {
535 if s.size[k], err = readUint64(r); err != nil {
536 return nil, err
537 }
538
539 total += s.size[k]
540 k++
541 }
542
543 s.size[k] = folder[i].unpackSize() - total
544 k++

Callers 1

readStreamsInfoFunction · 0.85

Calls 5

readUint64Function · 0.85
checkUint64Function · 0.85
readCRCFunction · 0.85
unpackSizeMethod · 0.80
ReadByteMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…