//Writer - returns the encrpyted writer for the given path
970080
func (s *EncryptedStorageProvider) Writer(path ...string) (cryptWriter io.WriteCloser, err error) {
	var unEncryptedWriter io.WriteCloser
	stream := s.getStream()

	if unEncryptedWriter, err = s.wrappedStorageProvider.Writer(path...); err == nil {
		cryptWriter = &cipher.StreamWriter{S: stream, W: unEncryptedWriter}
	}
	return
}
833985
func write(path string, d []byte) error {
	f, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY, keyPerm)
	if err != nil {
		return err
	}
	defer f.Close()
	// fInfo, err := f.Stat()
	// if err != nil {
	// 	return err
	// }
	// if fInfo.Mode() != keyPerm {
	// 	return tmerrors.NewErrPermissionsChanged(f.Name(), keyPerm, fInfo.Mode())
	// }
	_, err = f.Write(d)
	if err != nil {
		return err
	}
	err = f.Sync()
	return err
}
8805
func (c *Context) Write(path string, data []byte) error {
	if ae != nil {
		return ae.Write(c.ae, path, data)
	}
	return c.write(path, data)
}
1236822
func (m *MockPathio) Write(path string, input []byte) error {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Write", path, input)
	ret0, _ := ret[0].(error)
	return ret0
}
169064
func (muf *MutableForest) Writer(prefix []byte) (*RWTree, error) {
	// Try dirty cache first (if tree is new it may only be in this location)
	prefixString := string(prefix)
	if tree, ok := muf.dirty[prefixString]; ok {
		return tree, nil
	}
	tree, err := muf.tree(prefix)
	if err != nil {
		return nil, err
	}
	// Mark tree as dirty
	muf.dirty[prefixString] = tree
	muf.dirtyPrefixes = append(muf.dirtyPrefixes, prefixString)
	return tree, nil
}
818509
func (lw *LazyFile) Write(p []byte) (int, error) {
	if lw.file == nil {
		err := os.MkdirAll(path.Dir(lw.FileName), 0755)
		if err != nil {
			return 0, err
		}
		lw.file, err = os.Create(lw.FileName)
		if err != nil {
			return 0, err
		}
	}
	return lw.file.Write(p)
}
282782
func (w *Writer) Write(p []byte) (n int, err error) {
	var c int
	for len(p) > 0 && err == nil {
		s := p[:w.Limit(len(p), w.limit, w.block)]
		if len(s) > 0 {
			c, err = w.IO(w.Writer.Write(s))
		} else {
			return n, ErrLimit
		}
		p = p[c:]
		n += c
	}
	return
}
536112
func (f *File) commentsWriter() {
	for path, c := range f.Comments {
		if c != nil {
			v, _ := xml.Marshal(c)
			f.saveFileList(path, v)
		}
	}
}
1182871
func (f *StandaloneFile) Writer() (filesystem.Writer, error) {
	return f.filespace.Writer(f.path)
}
613934
func (l *Logger) Writer(severity int) io.Writer {
	logfunc := func(p []byte) (n int, err error) {
		for len(p) > 0 {
			eol := bytes.IndexByte(p, '\n')
			if eol == -1 {
				return
			}
			ln := eol + 1
			err = l.Log(severity, string(p[:eol]), nil)
			if err != nil {
				return
			}
			n += ln
			p = p[ln:]
		}
		return
	}

	return &logWriter{
		buf:     make([]byte, 0, maxLogSize/2),
		logfunc: logfunc,
	}
}
1333906
func (f *File) Write(ctx context.Context, req *fuse.WriteRequest,
	resp *fuse.WriteResponse) (err error) {
	sz := len(req.Data)
	ctx = f.folder.fs.config.MaybeStartTrace(ctx, "File.Write",
		fmt.Sprintf("%s sz=%d", f.node.GetBasename(), sz))
	defer func() { f.folder.fs.config.MaybeFinishTrace(ctx, err) }()

	f.folder.fs.vlog.CLogf(ctx, libkb.VLog1, "File Write sz=%d ", sz)
	defer func() { err = f.folder.processError(ctx, libkbfs.WriteMode, err) }()

	f.eiCache.destroy()
	if err := f.folder.fs.config.KBFSOps().Write(
		ctx, f.node, req.Data, req.Offset); err != nil {
		return err
	}
	resp.Size = len(req.Data)
	return nil
}
1110409
func StorageWriter(storage StorageAPI, volume, path string) io.Writer {
	return &storageWriter{storage, volume, path}
}
1093891
func (w *Writer) Write(p []byte) (n int, err error) {
	for i, b := range p {
		switch {
		// Simple writes are done in batch.
		case b >= '!' && b <= '~' && b != '=':
			continue
		case isWhitespace(b) || !w.Binary && (b == '\n' || b == '\r'):
			continue
		}

		if i > n {
			if err := w.write(p[n:i]); err != nil {
				return n, err
			}
			n = i
		}

		if err := w.encode(b); err != nil {
			return n, err
		}
		n++
	}

	if n == len(p) {
		return n, nil
	}

	if err := w.write(p[n:]); err != nil {
		return n, err
	}

	return len(p), nil
}
276503
func Write(path string, input []byte) error {
	return DefaultClient.Write(path, input)
}
537697
func WriteReader(path string, input io.ReadSeeker) error {
	return DefaultClient.WriteReader(path, input)
}
500561
func (c *Client) Write(path string, data []byte, _ os.FileMode) error {
	s := c.put(path, bytes.NewReader(data))
	switch s {

	case 200, 201, 204:
		return nil

	case 409:
		err := c.createParentCollection(path)
		if err != nil {
			return err
		}

		s = c.put(path, bytes.NewReader(data))
		if s == 200 || s == 201 || s == 204 {
			return nil
		}
	}

	return newPathError("Write", path, s)
}
818803
func (f *File) Write(reader io.Reader) (err error) {
	if f.HasPermission(roles.Update) {
		var dst *os.File
		if _, err = os.Stat(f.FilePath); os.IsNotExist(err) {
			err = os.MkdirAll(filepath.Dir(f.FilePath), os.ModePerm)
		}

		if err == nil {
			if dst, err = os.Create(f.FilePath); err == nil {
				_, err = io.Copy(dst, reader)
			}
		}
		return err
	}
	return roles.ErrPermissionDenied
}