MCPcopy Index your code
hub / github.com/IceWhaleTech/CasaOS / SortFiles

Function SortFiles

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

Source from the content-addressed store, hash-verified

51}
52
53func SortFiles(objs []Obj, orderBy, orderDirection string) {
54 if orderBy == "" {
55 return
56 }
57 sort.Slice(objs, func(i, j int) bool {
58 switch orderBy {
59 case "name":
60 {
61 c := natural.Less(objs[i].GetName(), objs[j].GetName())
62 if orderDirection == "desc" {
63 return !c
64 }
65 return c
66 }
67 case "size":
68 {
69 if orderDirection == "desc" {
70 return objs[i].GetSize() >= objs[j].GetSize()
71 }
72 return objs[i].GetSize() <= objs[j].GetSize()
73 }
74 case "modified":
75 if orderDirection == "desc" {
76 return objs[i].ModTime().After(objs[j].ModTime())
77 }
78 return objs[i].ModTime().Before(objs[j].ModTime())
79 }
80 return false
81 })
82}
83
84func ExtractFolder(objs []Obj, extractFolder string) {
85 if extractFolder == "" {

Callers

nothing calls this directly

Calls 3

GetNameMethod · 0.65
GetSizeMethod · 0.65
ModTimeMethod · 0.65

Tested by

no test coverage detected