Lines Matching refs:w

33 func NewWriter(w io.Writer) *Writer {
34 return &Writer{cw: &countWriter{w: bufio.NewWriter(w)}}
41 func (w *Writer) SetOffset(n int64) {
42 if w.cw.count != 0 {
45 w.cw.count = n
50 func (w *Writer) Flush() error {
51 return w.cw.w.(*bufio.Writer).Flush()
56 func (w *Writer) Close() error {
57 if w.last != nil && !w.last.closed {
58 if err := w.last.close(); err != nil {
61 w.last = nil
63 if w.closed {
66 w.closed = true
69 start := w.cw.count
70 for _, h := range w.dir {
111 if _, err := w.cw.Write(buf[:]); err != nil {
114 if _, err := io.WriteString(w.cw, h.Name); err != nil {
117 if _, err := w.cw.Write(h.Extra); err != nil {
120 if _, err := io.WriteString(w.cw, h.Comment); err != nil {
124 end := w.cw.count
126 records := uint64(len(w.dir))
152 if _, err := w.cw.Write(buf[:]); err != nil {
188 if _, err := w.cw.Write(buf[:]); err != nil {
192 return w.cw.w.(*bufio.Writer).Flush()
202 func (w *Writer) Create(name string) (io.Writer, error) {
207 return w.CreateHeader(header)
212 func (w *Writer) CreateHeader(fh *FileHeader) (io.Writer, error) {
214 return w.createHeaderImpl(fh)
228 func (w *Writer) createHeaderImpl(fh *FileHeader) (io.Writer, error) {
230 if w.last != nil && !w.last.closed {
231 if err := w.last.close(); err != nil {
235 if len(w.dir) > 0 && w.dir[len(w.dir)-1].FileHeader == fh {
246 zipw: w.cw,
247 compCount: &countWriter{w: w.cw},
250 comp := w.compressor(fh.Method)
259 fw.rawCount = &countWriter{w: fw.comp}
263 offset: uint64(w.cw.count),
265 w.dir = append(w.dir, h)
268 if err := writeHeader(w.cw, fh); err != nil {
272 w.last = fw
276 func writeHeader(w io.Writer, h *FileHeader) error {
325 if _, err := w.Write(buf[:]); err != nil {
328 if _, err := io.WriteString(w, h.Name); err != nil {
331 _, err := w.Write(h.Extra)
338 func (w *Writer) RegisterCompressor(method uint16, comp Compressor) {
339 if w.compressors == nil {
340 w.compressors = make(map[uint16]Compressor)
342 w.compressors[method] = comp
345 func (w *Writer) compressor(method uint16) Compressor {
346 comp := w.compressors[method]
363 func (w *fileWriter) Write(p []byte) (int, error) {
364 if w.closed {
367 w.crc32.Write(p)
368 return w.rawCount.Write(p)
372 func (w *fileWriter) close() (err error) {
374 if w.closed {
377 w.closed = true
378 if err := w.comp.Close(); err != nil {
383 fh := w.header.FileHeader
384 fh.CRC32 = w.crc32.Sum32()
385 fh.CompressedSize64 = uint64(w.compCount.count)
386 fh.UncompressedSize64 = uint64(w.rawCount.count)
420 _, err = w.zipw.Write(buf)
427 w io.Writer member
431 func (w *countWriter) Write(p []byte) (int, error) {
432 n, err := w.w.Write(p)
433 w.count += int64(n)
441 func (w nopCloser) Close() error {