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

Function readNames

types.go:685–728  ·  view source on GitHub ↗
(r util.Reader, count, length uint64)

Source from the content-addressed store, hash-verified

683}
684
685func readNames(r util.Reader, count, length uint64) ([]string, error) {
686 if err := checkUint64(count, true); err != nil {
687 return nil, err
688 }
689
690 external, err := r.ReadByte()
691 if err != nil {
692 return nil, fmt.Errorf("readNames: ReadByte error: %w", err)
693 }
694
695 if external > 0 {
696 /*
697 _, err := readUint64(r)
698 if err != nil {
699 return nil, err
700 }
701 */
702 // TODO Apparently we seek to this read offset and read the
703 // folder information from there. Not clear if the offset is
704 // absolute for the whole file, or relative to some known
705 // position in the file. Cowardly waiting for an example
706 return nil, errors.New("sevenzip: TODO readNames external") //nolint:err113
707 }
708
709 utf16le := unicode.UTF16(unicode.LittleEndian, unicode.IgnoreBOM)
710 scanner := bufio.NewScanner(transform.NewReader(io.LimitReader(r, int64(length-1)), utf16le.NewDecoder())) //nolint:gosec,lll
711 scanner.Split(splitNull)
712
713 names, i := make([]string, 0, count), uint64(0)
714 for scanner.Scan() {
715 names = append(names, scanner.Text())
716 i++
717 }
718
719 if err = scanner.Err(); err != nil {
720 return nil, fmt.Errorf("readNames: Scan error: %w", err)
721 }
722
723 if i != count {
724 return nil, errWrongNumberOfFilenames
725 }
726
727 return names, nil
728}
729
730func readAttributes(r util.Reader, count uint64) ([]uint32, error) {
731 if err := checkUint64(count, true); err != nil {

Callers 1

readFilesInfoFunction · 0.85

Calls 2

checkUint64Function · 0.85
ReadByteMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…