summaryrefslogtreecommitdiff
path: root/src/fsiter.rs
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2020-12-11 18:30:51 +0200
committerLars Wirzenius <liw@liw.fi>2020-12-11 19:02:18 +0200
commit81f8438e2375c9a2077303ab151f5968560484ed (patch)
treec4fd17ad3110a5f8ad4903a64ce5d6d66a054040 /src/fsiter.rs
parent0e1cfff1de7939cd1a36876258ec2b8a61aed0bb (diff)
downloadobnam2-81f8438e2375c9a2077303ab151f5968560484ed.tar.gz
refactor: how FsEntry structs are created
Now from a Metadata struct, instead of a bunch of field values. The justification for this is that callers shouldn't have to unpack a Metadata, especially since it'll be different for each operating system in the future. Keep all that in one place instead.
Diffstat (limited to 'src/fsiter.rs')
-rw-r--r--src/fsiter.rs8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/fsiter.rs b/src/fsiter.rs
index 929c81e..3c08179 100644
--- a/src/fsiter.rs
+++ b/src/fsiter.rs
@@ -28,10 +28,6 @@ impl Iterator for FsIterator {
fn new_entry(e: &walkdir::DirEntry) -> anyhow::Result<FilesystemEntry> {
let meta = e.metadata()?;
- let kind = if meta.is_dir() {
- FilesystemEntry::directory(e.path())
- } else {
- FilesystemEntry::regular(e.path(), meta.len())
- };
- Ok(kind)
+ let entry = FilesystemEntry::from_metadata(e.path(), &meta);
+ Ok(entry)
}