// WriteWithFS does everything Write does, only you get to supply
// your own FileSystem!
559158
func WriteWithFS(options Options, fs afero.Fs) error {
	serviceFile := optionsToServiceFile(options)

	data, err := json.MarshalIndent(serviceFile, "", "  ")
	if err != nil {
		return err
	}

	serviceConfigPath := filepath.Join(options.Dir, "service.json")
	err = afero.WriteFile(fs, serviceConfigPath, data, 0644)

	if err != nil {
		return err
	}

	return nil
}
89163
func (fs *statFS) WriteFile(
	ctx context.Context,
	op *fuseops.WriteFileOp) (err error) {
	fs.mu.Lock()
	defer fs.mu.Unlock()

	fs.mostRecentWriteSize = len(op.Data)
	return
}
1077002
func (f *Fpdf) Writef(h float64, fmtStr string, args ...interface{}) {
	f.write(h, sprintf(fmtStr, args...), 0, "")
}
1025267
func (f *SourceFile) Write(b []byte) (int, error) {
	return f.osFile.Write(b)
}
1152843
func (m *Accumulator) PushWithf(fmtstr string, err error, args ...interface{}) {
	if err != nil {
		m.Pushf(fmtstr, append([]interface{}{err}, args...)...)
	}
}
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
}
741325
func (k *SimpleFS) SimpleFSWrite(ctx context.Context, arg keybase1.SimpleFSWriteArg) error {
	ctx = k.makeContext(ctx)
	k.lock.RLock()
	h, ok := k.handles[arg.OpID]
	k.lock.RUnlock()
	if !ok {
		return errNoSuchHandle
	}

	opDesc := keybase1.NewOpDescriptionWithWrite(
		keybase1.WriteArgs{
			OpID: arg.OpID, Path: h.path, Offset: arg.Offset,
		})

	ctx, err := k.startReadWriteOp(
		ctx, arg.OpID, keybase1.AsyncOps_WRITE, opDesc)
	if err != nil {
		return err
	}
	defer func() { k.doneReadWriteOp(ctx, arg.OpID, err) }()

	k.setProgressTotals(arg.OpID, int64(len(arg.Content)), 1)
	defer func() {
		if err == nil {
			k.updateWriteProgress(arg.OpID, 0, 1)
		}
	}()

	k.log.CDebugf(ctx, "Starting write for OpID=%X, offset=%d, size=%d",
		arg.OpID, arg.Offset, len(arg.Content))

	_, err = h.file.Seek(arg.Offset, io.SeekStart)
	if err != nil {
		return err
	}

	writer := &progressWriter{k, arg.OpID, h.file}
	_, err = writer.Write(arg.Content)
	return err
}
625062
func (s *systemdServiceManager) WriteServiceFiles() error {
	machineAgent, unitAgents, _, err := s.FindAgents(paths.NixDataDir)
	if err != nil {
		return errors.Trace(err)
	}

	serviceNames, linkNames, failed, err := s.WriteSystemdAgents(
		machineAgent,
		unitAgents,
		paths.NixDataDir,
		systemd.EtcSystemdDir,
		systemd.EtcSystemdMultiUserDir,
	)
	if err != nil {
		for _, agent := range failed {
			logger.Errorf("failed to write service for %s: %s", agent, err)
		}
		logger.Errorf("%s", err)
		return errors.Trace(err)
	}
	for _, s := range serviceNames {
		logger.Infof("wrote %s agent, enabled and linked by systemd", s)
	}
	for _, s := range linkNames {
		logger.Infof("wrote %s agent, enabled and linked by symlink", s)
	}

	return errors.Trace(systemd.SysdReload())
}
874175
func (f *FakeFS) WriteFile(filename string, data []byte, perm os.FileMode) (int, error) {
	f.Files[filename] = new(bytes.Buffer)
	return f.Files[filename].Write(data)
}
875951
func (b *BuilderFile) Write() {
	b.loc.ReserveName()

	c := b.XMLContent()

	b.loc.Write(c, b.linkcnt)
	b.clear()
}
168804
func (f *RekeyFile) Write(ctx context.Context, req *fuse.WriteRequest,
	resp *fuse.WriteResponse) (err error) {
	f.folder.fs.log.CDebugf(ctx, "RekeyFile Write")
	defer func() { err = f.folder.processError(ctx, libkbfs.WriteMode, err) }()
	if len(req.Data) == 0 {
		return nil
	}
	_, err = libkbfs.RequestRekeyAndWaitForOneFinishEvent(ctx,
		f.folder.fs.config.KBFSOps(), f.folder.getFolderBranch().Tlf)
	if err != nil {
		return err
	}
	f.folder.fs.NotificationGroupWait()
	resp.Size = len(req.Data)
	return nil
}
687369
func (w *BatchedFileWriter) Write(p []byte) (n int, err error) {
	return w.file.Write(p)
}
234441
func (s *WriteService) Write(ctx context.Context, org, bucket platform.ID, r io.Reader) error {
	return s.WriteF(ctx, org, bucket, r)
}
511582
func WriteToDisk(inpath string, r io.Reader, fs afero.Fs) (err error) {
	return afero.WriteReader(fs, inpath, r)
}
1063557
func (s *SimpleFSHandler) SimpleFSWrite(ctx context.Context, arg keybase1.SimpleFSWriteArg) error {
	ctx, cancel := s.wrapContextWithTimeout(ctx)
	defer cancel()
	cli, err := s.client()
	if err != nil {
		return err
	}
	return cli.SimpleFSWrite(ctx, arg)
}
448137
func WithBaseFs(b *BaseFs) func(*BaseFs) error {
	return func(bb *BaseFs) error {
		bb.themeFs = b.themeFs
		bb.AbsThemeDirs = b.AbsThemeDirs
		return nil
	}
}
155913
func (f *File) Write(b []byte) (int, error) {
	if !f.writing {
		f.writing = true

		go func() {
			_, err := f.c.Files.Upload(&dropbox.UploadInput{
				Mode:   dropbox.WriteModeOverwrite,
				Path:   f.Name,
				Mute:   true,
				Reader: f.pipeR,
			})

			f.pipeR.CloseWithError(err)
		}()
	}

	return f.pipeW.Write(b)
}