github.com/searKing/golang/go@v1.2.117/os/file_info.go (about) 1 package os 2 3 import ( 4 "os" 5 ) 6 7 type FileInfos []os.FileInfo 8 9 func (s FileInfos) Len() int { 10 return len(s) 11 } 12 13 func (s FileInfos) Swap(i, j int) { 14 s[i], s[j] = s[j], s[i] 15 } 16 17 func (s FileInfos) Less(i, j int) bool { 18 return s[i].Name() < s[j].Name() 19 } 20 21 // WalkFileInfo is a wrapper for sort of filepath.WalkFunc 22 type WalkFileInfo struct { 23 Path string 24 FileInfo os.FileInfo 25 } 26 27 type WalkFileInfos []WalkFileInfo 28 29 func (w WalkFileInfos) Len() int { 30 return len(w) 31 } 32 33 func (w WalkFileInfos) Swap(i, j int) { 34 w[i], w[j] = w[j], w[i] 35 } 36 37 func (w WalkFileInfos) Less(i, j int) bool { 38 return w[i].Path < w[j].Path 39 }