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

Function readUnpackInfo

types.go:391–484  ·  view source on GitHub ↗

nolint:cyclop,funlen,gocognit

(r util.Reader)

Source from the content-addressed store, hash-verified

389
390//nolint:cyclop,funlen,gocognit
391func readUnpackInfo(r util.Reader) (*unpackInfo, error) {
392 u := new(unpackInfo)
393
394 if id, err := r.ReadByte(); err != nil || id != idFolder {
395 if err != nil {
396 return nil, fmt.Errorf("readUnpackInfo: ReadByte error: %w", err)
397 }
398
399 return nil, errUnexpectedID
400 }
401
402 folders, err := readUint64Bounded(r, true)
403 if err != nil {
404 return nil, err
405 }
406
407 external, err := r.ReadByte()
408 if err != nil {
409 return nil, fmt.Errorf("readUnpackInfo: ReadByte error: %w", err)
410 }
411
412 if external > 0 {
413 /*
414 _, err := readUint64(r)
415 if err != nil {
416 return nil, err
417 }
418 */
419 // TODO Apparently we seek to this read offset and read the
420 // folder information from there. Not clear if the offset is
421 // absolute for the whole file, or relative to some known
422 // position in the file. Cowardly waiting for an example
423 return nil, errors.New("sevenzip: TODO readUnpackInfo external") //nolint:err113
424 }
425
426 u.folder = make([]*folder, 0, min(folders, 1024))
427
428 for range folders {
429 folder, err := readFolder(r)
430 if err != nil {
431 return nil, err
432 }
433
434 u.folder = append(u.folder, folder)
435 }
436
437 if id, err := r.ReadByte(); err != nil || id != idCodersUnpackSize {
438 if err != nil {
439 return nil, fmt.Errorf("readUnpackInfo: ReadByte error: %w", err)
440 }
441
442 return nil, errUnexpectedID
443 }
444
445 for _, f := range u.folder {
446 total := uint64(0)
447 for _, c := range f.coder {
448 total += c.out

Callers 1

readStreamsInfoFunction · 0.85

Calls 6

readUint64BoundedFunction · 0.85
readFolderFunction · 0.85
checkUint64Function · 0.85
readUint64Function · 0.85
readCRCFunction · 0.85
ReadByteMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…