Skip to content

Commit

Permalink
file: Rename OverwriteFile() to Overwrite
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeKar committed May 24, 2024
1 parent ab044a8 commit 97a4e83
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion internal/buffer/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion internal/buffer/save.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion internal/buffer/serialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions internal/file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 97a4e83

Please sign in to comment.