| 253 | } |
| 254 | |
| 255 | func sortFileList(list []FileSearchInfo, sortBy, sortOrder string) { |
| 256 | switch sortBy { |
| 257 | case "name": |
| 258 | if sortOrder == "ascending" { |
| 259 | sort.Slice(list, func(i, j int) bool { |
| 260 | return list[i].Name() < list[j].Name() |
| 261 | }) |
| 262 | } else { |
| 263 | sort.Slice(list, func(i, j int) bool { |
| 264 | return list[i].Name() > list[j].Name() |
| 265 | }) |
| 266 | } |
| 267 | case "size": |
| 268 | if sortOrder == "ascending" { |
| 269 | sort.Slice(list, func(i, j int) bool { |
| 270 | return list[i].Size() < list[j].Size() |
| 271 | }) |
| 272 | } else { |
| 273 | sort.Slice(list, func(i, j int) bool { |
| 274 | return list[i].Size() > list[j].Size() |
| 275 | }) |
| 276 | } |
| 277 | case "modTime": |
| 278 | if sortOrder == "ascending" { |
| 279 | sort.Slice(list, func(i, j int) bool { |
| 280 | return list[i].ModTime().Before(list[j].ModTime()) |
| 281 | }) |
| 282 | } else { |
| 283 | sort.Slice(list, func(i, j int) bool { |
| 284 | return list[i].ModTime().After(list[j].ModTime()) |
| 285 | }) |
| 286 | } |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | func (f *FileInfo) listChildren(option FileOption) error { |
| 291 | var ( |