lockedfile

package
v0.9.2202 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2024 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Transform

func Transform(name string, t func([]byte) ([]byte, error)) (err error)

Transform invokes t with the result of reading the named file, with its lock still held.

If t returns a nil error, Transform then writes the returned contents back to the file, making a best effort to preserve existing contents on error.

t must not modify the slice passed to it.

func Write

func Write(name string, content io.Reader, perm fs.FileMode) (err error)

Write opens the named file (creating it with the given permissions if needed), then write-locks it and overwrites it with the given content.

Types

type File

type File struct {
	// contains filtered or unexported fields
}

func Create

func Create(name string) (*File, error)

Create is like os.Create, but returns a write-locked file.

func Open

func Open(name string) (*File, error)

Open is like os.Open, but returns a read-locked file.

func (*File) Close

func (f *File) Close() error

Close unlocks and closes the underlying file.

Close may be called multiple times; all calls after the first will return a non-nil error.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL