Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
18f51836
Commit
18f51836
authored
Feb 10, 2012
by
Nigel Tao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
compress: add comments to gzip and zlib.
Fixes #2939. R=rsc, r CC=golang-dev
https://golang.org/cl/5655050
parent
e0b2ce34
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
6 deletions
+20
-6
gunzip.go
src/pkg/compress/gzip/gunzip.go
+6
-2
gzip.go
src/pkg/compress/gzip/gzip.go
+2
-0
reader.go
src/pkg/compress/zlib/reader.go
+8
-3
writer.go
src/pkg/compress/zlib/writer.go
+4
-1
No files found.
src/pkg/compress/gzip/gunzip.go
View file @
18f51836
...
@@ -34,8 +34,12 @@ func makeReader(r io.Reader) flate.Reader {
...
@@ -34,8 +34,12 @@ func makeReader(r io.Reader) flate.Reader {
return
bufio
.
NewReader
(
r
)
return
bufio
.
NewReader
(
r
)
}
}
var
ErrHeader
=
errors
.
New
(
"invalid gzip header"
)
var
(
var
ErrChecksum
=
errors
.
New
(
"gzip checksum error"
)
// ErrChecksum is returned when reading GZIP data that has an invalid checksum.
ErrChecksum
=
errors
.
New
(
"gzip: invalid checksum"
)
// ErrHeader is returned when reading GZIP data that has an invalid header.
ErrHeader
=
errors
.
New
(
"gzip: invalid header"
)
)
// The gzip file stores a header giving metadata about the compressed file.
// The gzip file stores a header giving metadata about the compressed file.
// That header is exposed as the fields of the Writer and Reader structs.
// That header is exposed as the fields of the Writer and Reader structs.
...
...
src/pkg/compress/gzip/gzip.go
View file @
18f51836
...
@@ -130,6 +130,8 @@ func (z *Writer) writeString(s string) (err error) {
...
@@ -130,6 +130,8 @@ func (z *Writer) writeString(s string) (err error) {
return
err
return
err
}
}
// Write writes a compressed form of p to the underlying io.Writer. The
// compressed bytes are not necessarily flushed until the Writer is closed.
func
(
z
*
Writer
)
Write
(
p
[]
byte
)
(
int
,
error
)
{
func
(
z
*
Writer
)
Write
(
p
[]
byte
)
(
int
,
error
)
{
if
z
.
err
!=
nil
{
if
z
.
err
!=
nil
{
return
0
,
z
.
err
return
0
,
z
.
err
...
...
src/pkg/compress/zlib/reader.go
View file @
18f51836
...
@@ -34,9 +34,14 @@ import (
...
@@ -34,9 +34,14 @@ import (
const
zlibDeflate
=
8
const
zlibDeflate
=
8
var
ErrChecksum
=
errors
.
New
(
"zlib checksum error"
)
var
(
var
ErrHeader
=
errors
.
New
(
"invalid zlib header"
)
// ErrChecksum is returned when reading ZLIB data that has an invalid checksum.
var
ErrDictionary
=
errors
.
New
(
"invalid zlib dictionary"
)
ErrChecksum
=
errors
.
New
(
"zlib: invalid checksum"
)
// ErrDictionary is returned when reading ZLIB data that has an invalid dictionary.
ErrDictionary
=
errors
.
New
(
"zlib: invalid dictionary"
)
// ErrHeader is returned when reading ZLIB data that has an invalid header.
ErrHeader
=
errors
.
New
(
"zlib: invalid header"
)
)
type
reader
struct
{
type
reader
struct
{
r
flate
.
Reader
r
flate
.
Reader
...
...
src/pkg/compress/zlib/writer.go
View file @
18f51836
...
@@ -119,6 +119,9 @@ func (z *Writer) writeHeader() (err error) {
...
@@ -119,6 +119,9 @@ func (z *Writer) writeHeader() (err error) {
return
nil
return
nil
}
}
// Write writes a compressed form of p to the underlying io.Writer. The
// compressed bytes are not necessarily flushed until the Writer is closed or
// explicitly flushed.
func
(
z
*
Writer
)
Write
(
p
[]
byte
)
(
n
int
,
err
error
)
{
func
(
z
*
Writer
)
Write
(
p
[]
byte
)
(
n
int
,
err
error
)
{
if
!
z
.
wroteHeader
{
if
!
z
.
wroteHeader
{
z
.
err
=
z
.
writeHeader
()
z
.
err
=
z
.
writeHeader
()
...
@@ -138,7 +141,7 @@ func (z *Writer) Write(p []byte) (n int, err error) {
...
@@ -138,7 +141,7 @@ func (z *Writer) Write(p []byte) (n int, err error) {
return
return
}
}
// Flush flushes the
underlying compresso
r.
// Flush flushes the
Writer to its underlying io.Write
r.
func
(
z
*
Writer
)
Flush
()
error
{
func
(
z
*
Writer
)
Flush
()
error
{
if
!
z
.
wroteHeader
{
if
!
z
.
wroteHeader
{
z
.
err
=
z
.
writeHeader
()
z
.
err
=
z
.
writeHeader
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment