mirror of
https://github.com/golang/go
synced 2024-11-19 23:04:40 -07:00
archive/zip: add documentation about compression methods
Change-Id: I491c5ddd1a5d8e55f8e6bb9377bc3811e42773f8 Reviewed-on: https://go-review.googlesource.com/77870 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
c2eb9454a9
commit
a8474c799f
@ -27,8 +27,8 @@ import (
|
|||||||
|
|
||||||
// Compression methods.
|
// Compression methods.
|
||||||
const (
|
const (
|
||||||
Store uint16 = 0
|
Store uint16 = 0 // no compression
|
||||||
Deflate uint16 = 8
|
Deflate uint16 = 8 // DEFLATE compressed
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -102,7 +102,9 @@ type FileHeader struct {
|
|||||||
CreatorVersion uint16
|
CreatorVersion uint16
|
||||||
ReaderVersion uint16
|
ReaderVersion uint16
|
||||||
Flags uint16
|
Flags uint16
|
||||||
Method uint16
|
|
||||||
|
// Method is the compression method. If zero, Store is used.
|
||||||
|
Method uint16
|
||||||
|
|
||||||
// Modified is the modified time of the file.
|
// Modified is the modified time of the file.
|
||||||
//
|
//
|
||||||
@ -153,6 +155,8 @@ func (fi headerFileInfo) Sys() interface{} { return fi.fh }
|
|||||||
// Because os.FileInfo's Name method returns only the base name of
|
// Because os.FileInfo's Name method returns only the base name of
|
||||||
// the file it describes, it may be necessary to modify the Name field
|
// the file it describes, it may be necessary to modify the Name field
|
||||||
// of the returned header to provide the full path name of the file.
|
// of the returned header to provide the full path name of the file.
|
||||||
|
// If compression is desired, callers should set the FileHeader.Method
|
||||||
|
// field; it is unset by default.
|
||||||
func FileInfoHeader(fi os.FileInfo) (*FileHeader, error) {
|
func FileInfoHeader(fi os.FileInfo) (*FileHeader, error) {
|
||||||
size := fi.Size()
|
size := fi.Size()
|
||||||
fh := &FileHeader{
|
fh := &FileHeader{
|
||||||
|
@ -202,6 +202,7 @@ func (w *Writer) Close() error {
|
|||||||
|
|
||||||
// Create adds a file to the zip file using the provided name.
|
// Create adds a file to the zip file using the provided name.
|
||||||
// It returns a Writer to which the file contents should be written.
|
// It returns a Writer to which the file contents should be written.
|
||||||
|
// The file contents will be compressed using the Deflate method.
|
||||||
// The name must be a relative path: it must not start with a drive
|
// The name must be a relative path: it must not start with a drive
|
||||||
// letter (e.g. C:) or leading slash, and only forward slashes are
|
// letter (e.g. C:) or leading slash, and only forward slashes are
|
||||||
// allowed.
|
// allowed.
|
||||||
|
Loading…
Reference in New Issue
Block a user