goduf-byinode_unix.go
changeset 0 a5642cd03cef
child 3 d08d45871171
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/goduf-byinode_unix.go	Sat Jun 28 14:03:08 2014 +0200
@@ -0,0 +1,37 @@
+
+// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
+
+package main
+
+import "os"
+import "syscall"
+
+// ByInode is a FileObjList type with a sort interface
+type ByInode FileObjList
+
+func (a ByInode) Len() int      { return len(a) }
+func (a ByInode) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
+func (a ByInode) Less(i, j int) bool {
+	// Sort by device id first
+	iDevice := a[i].Sys().(*syscall.Stat_t).Dev
+	jDevice := a[j].Sys().(*syscall.Stat_t).Dev
+	switch {
+	case iDevice < jDevice:
+		return true
+	case iDevice > jDevice:
+		return false
+	}
+	iInode := a[i].Sys().(*syscall.Stat_t).Ino
+	jInode := a[j].Sys().(*syscall.Stat_t).Ino
+	return iInode < jInode
+}
+
+func OSHasInodes() bool {
+	return true
+}
+
+func GetDevIno(fi os.FileInfo) (uint64, uint64) {
+	dev := fi.Sys().(*syscall.Stat_t).Dev
+	ino := fi.Sys().(*syscall.Stat_t).Ino
+	return uint64(dev), uint64(ino)
+}