show size of selected files in header
This commit is contained in:
parent
ead10096d7
commit
b3f19bef73
4 changed files with 30 additions and 6 deletions
|
@ -28,7 +28,7 @@ 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
|
||||
return 0
|
||||
}
|
||||
return f.filesize
|
||||
}
|
||||
|
|
|
@ -42,11 +42,15 @@ func SortByModifiedReverse(a, b File) int {
|
|||
}
|
||||
|
||||
func SortBySize(a, b File) int {
|
||||
return cmp.Compare(b.Filesize(), a.Filesize())
|
||||
as := getSortingSize(a)
|
||||
bs := getSortingSize(b)
|
||||
return cmp.Compare(bs, as)
|
||||
}
|
||||
|
||||
func SortBySizeReverse(a, b File) int {
|
||||
return cmp.Compare(a.Filesize(), b.Filesize())
|
||||
as := getSortingSize(a)
|
||||
bs := getSortingSize(b)
|
||||
return cmp.Compare(as, bs)
|
||||
}
|
||||
|
||||
func SortByName(a, b File) int {
|
||||
|
@ -98,3 +102,11 @@ func SortDirectoriesLast(a, b File) int {
|
|||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
func getSortingSize(f File) int64 {
|
||||
if f.IsDir() {
|
||||
return -1
|
||||
} else {
|
||||
return f.Filesize()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ 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
|
||||
return 0
|
||||
}
|
||||
return t.filesize
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue