nolint:cyclop,funlen
()
| 668 | |
| 669 | //nolint:cyclop,funlen |
| 670 | func (z *Reader) initFileList() { |
| 671 | z.fileListOnce.Do(func() { |
| 672 | files := make(map[string]int) |
| 673 | knownDirs := make(map[string]int) |
| 674 | |
| 675 | dirs := make(map[string]struct{}) |
| 676 | |
| 677 | for _, file := range z.File { |
| 678 | isDir := len(file.Name) > 0 && file.Name[len(file.Name)-1] == '/' |
| 679 | |
| 680 | name := toValidName(file.Name) |
| 681 | if name == "" { |
| 682 | continue |
| 683 | } |
| 684 | |
| 685 | if idx, ok := files[name]; ok { |
| 686 | z.fileList[idx].isDup = true |
| 687 | |
| 688 | continue |
| 689 | } |
| 690 | |
| 691 | if idx, ok := knownDirs[name]; ok { |
| 692 | z.fileList[idx].isDup = true |
| 693 | |
| 694 | continue |
| 695 | } |
| 696 | |
| 697 | for dir := path.Dir(name); dir != "."; dir = path.Dir(dir) { |
| 698 | dirs[dir] = struct{}{} |
| 699 | } |
| 700 | |
| 701 | idx := len(z.fileList) |
| 702 | entry := fileListEntry{ |
| 703 | name: name, |
| 704 | file: file, |
| 705 | isDir: isDir, |
| 706 | } |
| 707 | z.fileList = append(z.fileList, entry) |
| 708 | |
| 709 | if isDir { |
| 710 | knownDirs[name] = idx |
| 711 | } else { |
| 712 | files[name] = idx |
| 713 | } |
| 714 | } |
| 715 | |
| 716 | for dir := range dirs { |
| 717 | if _, ok := knownDirs[dir]; !ok { |
| 718 | if idx, ok := files[dir]; ok { |
| 719 | z.fileList[idx].isDup = true |
| 720 | } else { |
| 721 | entry := fileListEntry{ |
| 722 | name: dir, |
| 723 | file: nil, |
| 724 | isDir: true, |
| 725 | } |
| 726 | z.fileList = append(z.fileList, entry) |
| 727 | } |
no test coverage detected