sorting preserves selection state
This commit is contained in:
parent
de81cfbfed
commit
0e147e283b
5 changed files with 108 additions and 115 deletions
|
@ -1,6 +1,7 @@
|
|||
package files
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
@ -31,6 +32,10 @@ func (f DiskFile) Filesize() int64 {
|
|||
return f.filesize
|
||||
}
|
||||
|
||||
func (f DiskFile) String() string {
|
||||
return fmt.Sprintf(string_format, f.name, f.path, f.modified.Format(time.UnixDate), f.filesize, f.isdir)
|
||||
}
|
||||
|
||||
func NewDisk(path string) (DiskFile, error) {
|
||||
info, err := os.Stat(path)
|
||||
if err != nil {
|
||||
|
|
|
@ -6,12 +6,15 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
const string_format = "%s %s %s %d %t"
|
||||
|
||||
type File interface {
|
||||
Name() string
|
||||
Path() string
|
||||
Date() time.Time
|
||||
Filesize() int64
|
||||
IsDir() bool
|
||||
String() string
|
||||
}
|
||||
|
||||
type Files []File
|
||||
|
|
|
@ -54,6 +54,10 @@ func (t TrashInfo) Filesize() int64 {
|
|||
return t.filesize
|
||||
}
|
||||
|
||||
func (t TrashInfo) String() string {
|
||||
return fmt.Sprintf(string_format, t.name, t.path, t.trashed.Format(time.UnixDate), t.filesize, t.isdir)
|
||||
}
|
||||
|
||||
func FindTrash(trashdir, ogdir string, f *filter.Filter) (files Files, outerr error) {
|
||||
outerr = filepath.WalkDir(trashdir, func(path string, d fs.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue