diff --git a/internal/files/files.go b/internal/files/files.go index 62efc89..ed409e4 100644 --- a/internal/files/files.go +++ b/internal/files/files.go @@ -7,6 +7,7 @@ import ( "os" "path/filepath" "slices" + "strings" "time" "git.burning.moe/celediel/gt/internal/filter" @@ -20,6 +21,7 @@ type File struct { name, path string filesize int64 modified time.Time + isdir bool } type Files []File @@ -29,6 +31,7 @@ func (f File) Path() string { return f.path } func (f File) Filename() string { return filepath.Join(f.path, f.name) } func (f File) Modified() time.Time { return f.modified } func (f File) Filesize() int64 { return f.filesize } +func (f File) IsDir() bool { return f.isdir } func (fls Files) Table(width int) string { // sort newest on top @@ -36,8 +39,13 @@ func (fls Files) Table(width int) string { data := [][]string{} for _, file := range fls { - t := humanize.Time(file.modified) - b := humanize.Bytes(uint64(file.filesize)) + var t, b string + t = humanize.Time(file.modified) + if file.isdir { + b = strings.Repeat("─", 3) + } else { + b = humanize.Bytes(uint64(file.filesize)) + } data = append(data, []string{ file.name, file.path, @@ -101,6 +109,7 @@ func walk_dir(dir string, f *filter.Filter) (files Files) { name: name, filesize: i.Size(), modified: i.ModTime(), + isdir: i.IsDir(), }) } else { log.Debugf("ignoring file %s (%s)", name, info.ModTime()) @@ -139,6 +148,7 @@ func read_dir(dir string, f *filter.Filter) (files Files) { path: path, modified: info.ModTime(), filesize: info.Size(), + isdir: info.IsDir(), }) } else { log.Debugf("ignoring file %s (%s)", name, info.ModTime()) diff --git a/internal/trash/trash.go b/internal/trash/trash.go index ad1c77a..b254037 100644 --- a/internal/trash/trash.go +++ b/internal/trash/trash.go @@ -34,6 +34,7 @@ DeletionDate={date}` type Info struct { name, ogpath string path, trashinfo string + isdir bool trashed time.Time filesize int64 } @@ -46,6 +47,7 @@ func (i Info) OGPath() string { return i.ogpath } func (i Info) TrashInfo() string { return i.trashinfo } func (i Info) Trashed() time.Time { return i.trashed } func (i Info) Filesize() int64 { return i.filesize } +func (i Info) IsDir() bool { return i.isdir } func (is Infos) Table(width int) string { @@ -53,8 +55,13 @@ func (is Infos) Table(width int) string { slices.SortStableFunc(is, SortByTrashedReverse) out := [][]string{} for _, file := range is { - t := humanize.Time(file.trashed) - b := humanize.Bytes(uint64(file.filesize)) + var t, b string + t = humanize.Time(file.trashed) + if file.isdir { + b = strings.Repeat("─", 3) + } else { + b = humanize.Bytes(uint64(file.filesize)) + } out = append(out, []string{ file.name, filepath.Dir(file.ogpath), @@ -119,6 +126,7 @@ func FindFiles(trashdir, ogdir string, f *filter.Filter) (files Infos, outerr er ogpath: basepath, trashinfo: path, trashed: date, + isdir: info.IsDir(), filesize: info.Size(), }) } else {