2 glocate -- ZFS-diff-friendly locate-like utility
3 Copyright (C) 2022-2023 Sergey Matveev <stargrave@stargrave.org>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, version 3 of the License.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
32 func walker(sink chan Ent, root []string) error {
33 files, err := os.ReadDir(path.Join(root...)) // it is already sorted
38 ents := make([]Ent, 0, len(files))
39 for _, file := range files {
40 ent := Ent{name: append([]string{}, append(root, file.Name())...)}
41 info, err = file.Info()
44 ent.name[len(ent.name)-1] += "/"
45 } else if info.Mode().IsRegular() {
46 ent.size = info.Size()
48 ent.mtime = info.ModTime().Unix()
50 log.Println("can not stat:", path.Join(ent.name...), ":", err)
52 ents = append(ents, ent)
54 for _, ent := range ents {
62 err = walker(sink, ent.name)
64 log.Println("can not stat:", path.Join(ent.name...), ":", err)