handlekeeper

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2019 License: MIT Imports: 3 Imported by: 1

README

handlekeeper

GoDoc Go Report Card

handlekeeper is a wrapper for os.OpenFile(). It intends to help applications with keeping track of active textfiles by presenting stable file handles even when the opened files are moved away or deleted. This is achieved by instantly creating a new, empty file in the location of the original file, and re-opening the corresponding filehandle internally.

Usage

hk, _ := handlekeeper.NewHandlekeeper("/some/file.txt")

Now, hk.Handle is an ordinary *os.File and can be used as usual:

Screenshot

Note

The handle only stays stable over delete (or move-away) events on the handled file. Truncating the file (as in logrotate's copy-truncate for example) will still break the handle.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handlekeeper

type Handlekeeper struct {
	Handle *os.File
}

func NewHandlekeeper

func NewHandlekeeper(file string) (*Handlekeeper, error)

func (*Handlekeeper) Close

func (hk *Handlekeeper) Close() error

Jump to

Keyboard shortcuts

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