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

Function readHeader

types.go:888–958  ·  view source on GitHub ↗

nolint:cyclop,funlen

(r util.Reader)

Source from the content-addressed store, hash-verified

886
887//nolint:cyclop,funlen
888func readHeader(r util.Reader) (*header, error) {
889 h := new(header)
890
891 id, err := r.ReadByte()
892 if err != nil {
893 return nil, fmt.Errorf("readHeader: ReadByte error: %w", err)
894 }
895
896 if id == idArchiveProperties {
897 /*
898 id, err = r.ReadByte()
899 if err != nil {
900 return nil, fmt.Errorf("readHeader: ReadByte error: %w", err)
901 }
902 */
903 return nil, errors.New("sevenzip: TODO idArchiveProperties") //nolint:err113
904 }
905
906 if id == idAdditionalStreamsInfo {
907 /*
908 id, err = r.ReadByte()
909 if err != nil {
910 return nil, fmt.Errorf("readHeader: ReadByte error: %w", err)
911 }
912 */
913 return nil, errors.New("sevenzip: TODO idAdditionalStreamsInfo") //nolint:err113
914 }
915
916 if id == idMainStreamsInfo {
917 if h.streamsInfo, err = readStreamsInfo(r); err != nil {
918 return nil, err
919 }
920
921 id, err = r.ReadByte()
922 if err != nil {
923 return nil, fmt.Errorf("readHeader: ReadByte error: %w", err)
924 }
925 }
926
927 if id == idFilesInfo {
928 if h.filesInfo, err = readFilesInfo(r); err != nil {
929 return nil, err
930 }
931
932 id, err = r.ReadByte()
933 if err != nil {
934 return nil, fmt.Errorf("readHeader: ReadByte error: %w", err)
935 }
936 }
937
938 if id != idEnd {
939 return nil, errUnexpectedID
940 }
941
942 if h.streamsInfo == nil || h.filesInfo == nil {
943 return h, nil
944 }
945

Callers 2

readEncodedHeaderFunction · 0.85
initMethod · 0.85

Calls 4

readStreamsInfoFunction · 0.85
readFilesInfoFunction · 0.85
FileFolderAndSizeMethod · 0.80
ReadByteMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…