Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(117)

Side by Side Diff: src/pkg/archive/zip/reader.go

Issue 5645051: code review 5645051: archive/zip: tweak API and docs. (Closed)
Patch Set: diff -r 37a5f3ad9990 https://go.googlecode.com/hg Created 12 years, 1 month ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/pkg/archive/zip/writer.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 The Go Authors. All rights reserved. 1 // Copyright 2010 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package zip 5 package zip
6 6
7 import ( 7 import (
8 "bufio" 8 "bufio"
9 "compress/flate" 9 "compress/flate"
10 "encoding/binary" 10 "encoding/binary"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 } 110 }
111 return nil 111 return nil
112 } 112 }
113 113
114 // Close closes the Zip file, rendering it unusable for I/O. 114 // Close closes the Zip file, rendering it unusable for I/O.
115 func (rc *ReadCloser) Close() error { 115 func (rc *ReadCloser) Close() error {
116 return rc.f.Close() 116 return rc.f.Close()
117 } 117 }
118 118
119 // Open returns a ReadCloser that provides access to the File's contents. 119 // Open returns a ReadCloser that provides access to the File's contents.
120 // It is safe to Open and Read from files concurrently. 120 // Multiple files may be read concurrently.
121 func (f *File) Open() (rc io.ReadCloser, err error) { 121 func (f *File) Open() (rc io.ReadCloser, err error) {
122 bodyOffset, err := f.findBodyOffset() 122 bodyOffset, err := f.findBodyOffset()
123 if err != nil { 123 if err != nil {
124 return 124 return
125 } 125 }
126 size := int64(f.CompressedSize) 126 size := int64(f.CompressedSize)
127 if size == 0 && f.hasDataDescriptor() { 127 if size == 0 && f.hasDataDescriptor() {
128 // permit SectionReader to see the rest of the file 128 // permit SectionReader to see the rest of the file
129 size = f.zipsize - (f.headerOffset + bodyOffset) 129 size = f.zipsize - (f.headerOffset + bodyOffset)
130 } 130 }
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 if b[i] == 'P' && b[i+1] == 'K' && b[i+2] == 0x05 && b[i+3] == 0 x06 { 304 if b[i] == 'P' && b[i+1] == 'K' && b[i+2] == 0x05 && b[i+3] == 0 x06 {
305 // n is length of comment 305 // n is length of comment
306 n := int(b[i+directoryEndLen-2]) | int(b[i+directoryEndL en-1])<<8 306 n := int(b[i+directoryEndLen-2]) | int(b[i+directoryEndL en-1])<<8
307 if n+directoryEndLen+i == len(b) { 307 if n+directoryEndLen+i == len(b) {
308 return i 308 return i
309 } 309 }
310 } 310 }
311 } 311 }
312 return -1 312 return -1
313 } 313 }
OLDNEW
« no previous file with comments | « no previous file | src/pkg/archive/zip/writer.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b