add flag to filter by file mode

This commit is contained in:
Lilian Jónsdóttir 2024-07-15 21:05:21 -07:00
parent 40ef230a4f
commit 940a2fc14f
6 changed files with 132 additions and 32 deletions

View file

@ -18,12 +18,14 @@ type DiskFile struct {
filesize int64
modified time.Time
isdir bool
mode fs.FileMode
}
func (f DiskFile) Name() string { return f.name }
func (f DiskFile) Path() string { return f.path }
func (f DiskFile) Date() time.Time { return f.modified }
func (f DiskFile) IsDir() bool { return f.isdir }
func (f DiskFile) Name() string { return f.name }
func (f DiskFile) Path() string { return f.path }
func (f DiskFile) Date() time.Time { return f.modified }
func (f DiskFile) IsDir() bool { return f.isdir }
func (f DiskFile) Mode() fs.FileMode { return f.mode }
func (f DiskFile) Filesize() int64 {
if f.isdir {
return -1
@ -61,6 +63,7 @@ func NewDisk(path string) (DiskFile, error) {
filesize: info.Size(),
modified: info.ModTime(),
isdir: info.IsDir(),
mode: info.Mode(),
}, nil
}
@ -170,6 +173,7 @@ func read_dir(dir string, f *filter.Filter) (files Files) {
modified: info.ModTime(),
filesize: info.Size(),
isdir: info.IsDir(),
mode: info.Mode(),
})
}
}

View file

@ -3,6 +3,7 @@ package files
import (
"cmp"
"io/fs"
"strings"
"time"
)
@ -13,6 +14,7 @@ type File interface {
Date() time.Time
Filesize() int64
IsDir() bool
Mode() fs.FileMode
String() string
}

View file

@ -39,6 +39,7 @@ type TrashInfo struct {
isdir bool
trashed time.Time
filesize int64
mode fs.FileMode
}
func (t TrashInfo) Name() string { return t.name }
@ -47,6 +48,7 @@ func (t TrashInfo) Path() string { return t.ogpath }
func (t TrashInfo) TrashInfo() string { return t.trashinfo }
func (t TrashInfo) Date() time.Time { return t.trashed }
func (t TrashInfo) IsDir() bool { return t.isdir }
func (t TrashInfo) Mode() fs.FileMode { return t.mode }
func (t TrashInfo) Filesize() int64 {
if t.isdir {
return -1