equal
deleted
inserted
replaced
|
1 |
|
2 // +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris |
|
3 |
|
4 package main |
|
5 |
|
6 import "os" |
|
7 import "syscall" |
|
8 |
|
9 // ByInode is a FileObjList type with a sort interface |
|
10 type ByInode FileObjList |
|
11 |
|
12 func (a ByInode) Len() int { return len(a) } |
|
13 func (a ByInode) Swap(i, j int) { a[i], a[j] = a[j], a[i] } |
|
14 func (a ByInode) Less(i, j int) bool { |
|
15 // Sort by device id first |
|
16 iDevice := a[i].Sys().(*syscall.Stat_t).Dev |
|
17 jDevice := a[j].Sys().(*syscall.Stat_t).Dev |
|
18 switch { |
|
19 case iDevice < jDevice: |
|
20 return true |
|
21 case iDevice > jDevice: |
|
22 return false |
|
23 } |
|
24 iInode := a[i].Sys().(*syscall.Stat_t).Ino |
|
25 jInode := a[j].Sys().(*syscall.Stat_t).Ino |
|
26 return iInode < jInode |
|
27 } |
|
28 |
|
29 func OSHasInodes() bool { |
|
30 return true |
|
31 } |
|
32 |
|
33 func GetDevIno(fi os.FileInfo) (uint64, uint64) { |
|
34 dev := fi.Sys().(*syscall.Stat_t).Dev |
|
35 ino := fi.Sys().(*syscall.Stat_t).Ino |
|
36 return uint64(dev), uint64(ino) |
|
37 } |