diff --git a/internal/buffer/backup.go b/internal/buffer/backup.go index 03bd52901d..6799ebcc1a 100644 --- a/internal/buffer/backup.go +++ b/internal/buffer/backup.go @@ -81,7 +81,7 @@ func (b *Buffer) Backup() error { name := filepath.Join(backupdir, util.EscapePath(b.AbsPath)) - err = file.OverwriteFile(name, func(file io.Writer) (e error) { + err = file.Overwrite(name, func(file io.Writer) (e error) { b.Lock() defer b.Unlock() diff --git a/internal/buffer/save.go b/internal/buffer/save.go index ffdb59adb9..f937fae063 100644 --- a/internal/buffer/save.go +++ b/internal/buffer/save.go @@ -192,7 +192,7 @@ func (b *Buffer) saveToFile(filename string, withSudo bool, autoSave bool) error } optSteps := file.OptionalWriteSteps{PreWrite: preWrite, PostWrite: postWrite} - if err = file.OverwriteFile(absFilename, write, optSteps); err != nil { + if err = file.Overwrite(absFilename, write, optSteps); err != nil { return err } diff --git a/internal/buffer/serialize.go b/internal/buffer/serialize.go index 7ac86b3bfa..1b6f0e0cdd 100644 --- a/internal/buffer/serialize.go +++ b/internal/buffer/serialize.go @@ -32,7 +32,7 @@ func (b *Buffer) Serialize() error { name := filepath.Join(config.ConfigDir, "buffers", util.EscapePath(b.AbsPath)) - return file.OverwriteFile(name, func(file io.Writer) error { + return file.Overwrite(name, func(file io.Writer) error { err := gob.NewEncoder(file).Encode(SerializedBuffer{ b.EventHandler, b.GetActiveCursor().Loc, diff --git a/internal/file/file.go b/internal/file/file.go index 962abe432b..48d7da7f03 100644 --- a/internal/file/file.go +++ b/internal/file/file.go @@ -14,10 +14,10 @@ type OptionalWriteSteps struct { PostWrite func() error } -// OverwriteFile opens the given file for writing, truncating if one exists, and then calls +// Overwrite opens the given file for writing, truncating if one exists, and then calls // the supplied function with the file as io.Writer object, also making sure the file is // closed afterwards. -func OverwriteFile(name string, write func(io.Writer) error, optSteps ...OptionalWriteSteps) (err error) { +func Overwrite(name string, write func(io.Writer) error, optSteps ...OptionalWriteSteps) (err error) { var writeCloser io.WriteCloser enc := encoding.Nop for _, optional := range optSteps {