2017-05-15 17:13:34 -04:00
|
|
|
package fsutil
|
|
|
|
|
|
|
|
import (
|
2018-06-08 21:07:42 -04:00
|
|
|
"context"
|
2017-09-29 06:32:26 -04:00
|
|
|
"hash"
|
2017-05-15 17:13:34 -04:00
|
|
|
"os"
|
2018-10-05 05:05:42 -04:00
|
|
|
|
|
|
|
"github.com/tonistiigi/fsutil/types"
|
2017-05-15 17:13:34 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
type walkerFn func(ctx context.Context, pathC chan<- *currentPath) error
|
|
|
|
|
|
|
|
func Changes(ctx context.Context, a, b walkerFn, changeFn ChangeFunc) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type HandleChangeFn func(ChangeKind, string, os.FileInfo, error) error
|
|
|
|
|
2018-10-05 05:05:42 -04:00
|
|
|
type ContentHasher func(*types.Stat) (hash.Hash, error)
|
2017-09-29 06:32:26 -04:00
|
|
|
|
2017-05-15 17:13:34 -04:00
|
|
|
func GetWalkerFn(root string) walkerFn {
|
|
|
|
return func(ctx context.Context, pathC chan<- *currentPath) error {
|
|
|
|
return Walk(ctx, root, nil, func(path string, f os.FileInfo, err error) error {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
p := ¤tPath{
|
|
|
|
path: path,
|
|
|
|
f: f,
|
|
|
|
}
|
|
|
|
|
|
|
|
select {
|
|
|
|
case <-ctx.Done():
|
|
|
|
return ctx.Err()
|
|
|
|
case pathC <- p:
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2017-09-29 06:32:26 -04:00
|
|
|
|
|
|
|
func emptyWalker(ctx context.Context, pathC chan<- *currentPath) error {
|
|
|
|
return nil
|
|
|
|
}
|