simplify file object
This commit is contained in:
+13
-4
@@ -75,8 +75,8 @@ func (s *Scanner) scan(rootDir, dir string, yield func(*File) bool) {
|
||||
continue
|
||||
}
|
||||
|
||||
f := NewFile(rootDir, absPath)
|
||||
if len(s.extensions) > 0 && !slices.Contains(s.extensions, f.Extension) {
|
||||
relPath, relDir, filename, extension := ParsePath(rootDir, absPath)
|
||||
if len(s.extensions) > 0 && !slices.Contains(s.extensions, extension) {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -86,8 +86,17 @@ func (s *Scanner) scan(rootDir, dir string, yield func(*File) bool) {
|
||||
continue
|
||||
}
|
||||
|
||||
f.Size = info.Size()
|
||||
f.Modified = info.ModTime()
|
||||
f := &File{
|
||||
RootDir: rootDir,
|
||||
AbsolutePath: absPath,
|
||||
RelativeDir: relDir,
|
||||
RelativePath: relPath,
|
||||
Filename: filename,
|
||||
Extension: extension,
|
||||
Size: info.Size(),
|
||||
Modified: info.ModTime(),
|
||||
}
|
||||
|
||||
if !yield(f) {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user