(objs []Obj, orderBy, orderDirection string)
| 84 | } |
| 85 | |
| 86 | func 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 | |
| 117 | func ExtractFolder(objs []Obj, extractFolder string) { |
| 118 | if extractFolder == "" { |
no test coverage detected