Skip to content

package filechange

import "github.com/cloudboss/unobin/pkg/filechange"

Types

type Action

type Action string

type Change

type Change struct {
    Path   string `json:"path"   ub:"path"`
    Action Action `json:"action" ub:"action"`
}

func Compose

func Compose(changes []Change) ([]Change, error)

func Observe

func Observe(paths []string, mutate func() error) ([]Change, error)

Observe runs mutate once and reports the resulting actions for paths.

func Sort

func Sort(changes []Change) []Change

func WriteFile

func WriteFile(path string, content []byte, mode fs.FileMode) (Change, error)

WriteFile atomically writes content and reports the resulting file action.