@@ -121,25 +121,25 @@ func NewReader(r io.ReaderAt, size int64) (*Reader, error) {
121
121
return zr , nil
122
122
}
123
123
124
- func (z * Reader ) init (r io.ReaderAt , size int64 ) error {
125
- end , baseOffset , err := readDirectoryEnd (r , size )
124
+ func (r * Reader ) init (rdr io.ReaderAt , size int64 ) error {
125
+ end , baseOffset , err := readDirectoryEnd (rdr , size )
126
126
if err != nil {
127
127
return err
128
128
}
129
- z .r = r
130
- z .baseOffset = baseOffset
129
+ r .r = rdr
130
+ r .baseOffset = baseOffset
131
131
// Since the number of directory records is not validated, it is not
132
- // safe to preallocate z .File without first checking that the specified
132
+ // safe to preallocate r .File without first checking that the specified
133
133
// number of files is reasonable, since a malformed archive may
134
134
// indicate it contains up to 1 << 128 - 1 files. Since each file has a
135
135
// header which will be _at least_ 30 bytes we can safely preallocate
136
136
// if (data size / 30) >= end.directoryRecords.
137
137
if end .directorySize < uint64 (size ) && (uint64 (size )- end .directorySize )/ 30 >= end .directoryRecords {
138
- z .File = make ([]* File , 0 , end .directoryRecords )
138
+ r .File = make ([]* File , 0 , end .directoryRecords )
139
139
}
140
- z .Comment = end .comment
141
- rs := io .NewSectionReader (r , 0 , size )
142
- if _ , err = rs .Seek (z .baseOffset + int64 (end .directoryOffset ), io .SeekStart ); err != nil {
140
+ r .Comment = end .comment
141
+ rs := io .NewSectionReader (rdr , 0 , size )
142
+ if _ , err = rs .Seek (r .baseOffset + int64 (end .directoryOffset ), io .SeekStart ); err != nil {
143
143
return err
144
144
}
145
145
buf := bufio .NewReader (rs )
@@ -149,18 +149,18 @@ func (z *Reader) init(r io.ReaderAt, size int64) error {
149
149
// a bad one, and then only report an ErrFormat or UnexpectedEOF if
150
150
// the file count modulo 65536 is incorrect.
151
151
for {
152
- f := & File {zip : z , zipr : r }
152
+ f := & File {zip : r , zipr : rdr }
153
153
err = readDirectoryHeader (f , buf )
154
154
if err == ErrFormat || err == io .ErrUnexpectedEOF {
155
155
break
156
156
}
157
157
if err != nil {
158
158
return err
159
159
}
160
- f .headerOffset += z .baseOffset
161
- z .File = append (z .File , f )
160
+ f .headerOffset += r .baseOffset
161
+ r .File = append (r .File , f )
162
162
}
163
- if uint16 (len (z .File )) != uint16 (end .directoryRecords ) { // only compare 16 bits here
163
+ if uint16 (len (r .File )) != uint16 (end .directoryRecords ) { // only compare 16 bits here
164
164
// Return the readDirectoryHeader error if we read
165
165
// the wrong number of directory entries.
166
166
return err
@@ -171,15 +171,15 @@ func (z *Reader) init(r io.ReaderAt, size int64) error {
171
171
// RegisterDecompressor registers or overrides a custom decompressor for a
172
172
// specific method ID. If a decompressor for a given method is not found,
173
173
// Reader will default to looking up the decompressor at the package level.
174
- func (z * Reader ) RegisterDecompressor (method uint16 , dcomp Decompressor ) {
175
- if z .decompressors == nil {
176
- z .decompressors = make (map [uint16 ]Decompressor )
174
+ func (r * Reader ) RegisterDecompressor (method uint16 , dcomp Decompressor ) {
175
+ if r .decompressors == nil {
176
+ r .decompressors = make (map [uint16 ]Decompressor )
177
177
}
178
- z .decompressors [method ] = dcomp
178
+ r .decompressors [method ] = dcomp
179
179
}
180
180
181
- func (z * Reader ) decompressor (method uint16 ) Decompressor {
182
- dcomp := z .decompressors [method ]
181
+ func (r * Reader ) decompressor (method uint16 ) Decompressor {
182
+ dcomp := r .decompressors [method ]
183
183
if dcomp == nil {
184
184
dcomp = decompressor (method )
185
185
}
@@ -740,14 +740,14 @@ type fileInfoDirEntry interface {
740
740
fs.DirEntry
741
741
}
742
742
743
- func (e * fileListEntry ) stat () (fileInfoDirEntry , error ) {
744
- if e .isDup {
745
- return nil , errors .New (e .name + ": duplicate entries in zip file" )
743
+ func (f * fileListEntry ) stat () (fileInfoDirEntry , error ) {
744
+ if f .isDup {
745
+ return nil , errors .New (f .name + ": duplicate entries in zip file" )
746
746
}
747
- if ! e .isDir {
748
- return headerFileInfo {& e .file .FileHeader }, nil
747
+ if ! f .isDir {
748
+ return headerFileInfo {& f .file .FileHeader }, nil
749
749
}
750
- return e , nil
750
+ return f , nil
751
751
}
752
752
753
753
// Only used for directories.
0 commit comments