2017-05-04 00:49:12 -04:00
|
|
|
package fsutil
|
|
|
|
|
|
|
|
import (
|
2018-06-08 20:39:07 -04:00
|
|
|
"context"
|
2017-09-21 20:54:27 -04:00
|
|
|
"hash"
|
2017-05-04 00:49:12 -04:00
|
|
|
"os"
|
2018-10-05 05:04:52 -04:00
|
|
|
|
|
|
|
"github.com/tonistiigi/fsutil/types"
|
2017-05-04 00:49:12 -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:04:52 -04:00
|
|
|
type ContentHasher func(*types.Stat) (hash.Hash, error)
|
2017-09-21 20:54:27 -04:00
|
|
|
|
2017-05-04 00:49:12 -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-21 20:54:27 -04:00
|
|
|
|
|
|
|
func emptyWalker(ctx context.Context, pathC chan<- *currentPath) error {
|
|
|
|
return nil
|
|
|
|
}
|