code: func NewWriter(dir string) (*Writer, error) {
  	if err := os.MkdirAll(dir, 0777); err != nil {
  		return nil, err
  	}
  	dirFile, err := fileutil.OpenDir(dir)
  	if err != nil {
  		return nil, err
  	}
  	cw := &Writer{
  		dirFile:     dirFile,
  		n:           0,
  		crc32:       newCRC32(),
  		segmentSize: defaultChunkSegmentSize,
  	}
  	return cw, nil
  }
docs: // NewWriter returns a new writer against the given directory.