MCPcopy Create free account
hub / github.com/OpenListTeam/OpenList / SortFiles

Function SortFiles

internal/model/obj.go:86–115  ·  view source on GitHub ↗
(objs []Obj, orderBy, orderDirection string)

Source from the content-addressed store, hash-verified

84}
85
86func SortFiles(objs []Obj, orderBy, orderDirection string) {
87 if orderBy == "" {
88 return
89 }
90 sort.Slice(objs, func(i, j int) bool {
91 switch orderBy {
92 case "name":
93 {
94 c := natural.Less(objs[i].GetName(), objs[j].GetName())
95 if orderDirection == "desc" {
96 return !c
97 }
98 return c
99 }
100 case "size":
101 {
102 if orderDirection == "desc" {
103 return objs[i].GetSize() >= objs[j].GetSize()
104 }
105 return objs[i].GetSize() <= objs[j].GetSize()
106 }
107 case "modified":
108 if orderDirection == "desc" {
109 return objs[i].ModTime().After(objs[j].ModTime())
110 }
111 return objs[i].ModTime().Before(objs[j].ModTime())
112 }
113 return false
114 })
115}
116
117func ExtractFolder(objs []Obj, extractFolder string) {
118 if extractFolder == "" {

Callers 5

ListMethod · 0.92
listFunction · 0.92
ListArchiveFunction · 0.92
GetSortedObjectsMethod · 0.92
listFunction · 0.92

Calls 4

GetNameMethod · 0.65
GetSizeMethod · 0.65
ModTimeMethod · 0.65
LessMethod · 0.45

Tested by

no test coverage detected