summaryrefslogtreecommitdiff
path: root/internal/scan/scan.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/scan/scan.go')
-rw-r--r--internal/scan/scan.go29
1 files changed, 21 insertions, 8 deletions
diff --git a/internal/scan/scan.go b/internal/scan/scan.go
index 7fe9e92..77cca66 100644
--- a/internal/scan/scan.go
+++ b/internal/scan/scan.go
@@ -24,6 +24,26 @@ type File struct {
Size int64
ModTime time.Time
Mode fs.FileMode
+
+ // Dev and Ino identify the file on its filesystem; both are 0 where the
+ // platform reports neither.
+ Dev, Ino uint64
+}
+
+// NewFile builds the File for path, at rel under the root, from its Lstat
+// info.
+func NewFile(path, rel string, info fs.FileInfo) File {
+ dev, ino := fileID(info)
+ return File{
+ Path: path,
+ Rel: rel,
+ Name: filepath.Base(path),
+ Size: info.Size(),
+ ModTime: info.ModTime(),
+ Mode: info.Mode(),
+ Dev: dev,
+ Ino: ino,
+ }
}
// Reason is why an entry was not returned as a File.
@@ -217,14 +237,7 @@ func (w *walker) walk(dir, relDir string, depth int, entries []os.DirEntry) erro
w.result.Skipped = append(w.result.Skipped, Skipped{Rel: rel, Reason: TooBig})
continue
}
- w.result.Files = append(w.result.Files, File{
- Path: path,
- Rel: rel,
- Name: name,
- Size: info.Size(),
- ModTime: info.ModTime(),
- Mode: info.Mode(),
- })
+ w.result.Files = append(w.result.Files, NewFile(path, rel, info))
}
return nil
}