-
Notifications
You must be signed in to change notification settings - Fork 9
/
api_darwin.go
49 lines (45 loc) · 1.26 KB
/
api_darwin.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// +build darwin
package lfs
import (
"os"
"syscall"
"github.com/yuin/gopher-lua"
)
func attributesFill(tbl *lua.LTable, stat os.FileInfo) error {
sys := stat.Sys().(*syscall.Stat_t)
tbl.RawSetString("dev", lua.LNumber(sys.Dev))
tbl.RawSetString("ino", lua.LNumber(sys.Ino))
{
var mode string
switch sys.Mode & syscall.S_IFMT {
case syscall.S_IFREG:
mode = "file"
case syscall.S_IFDIR:
mode = "directory"
case syscall.S_IFLNK:
mode = "link"
case syscall.S_IFSOCK:
mode = "socket"
case syscall.S_IFIFO:
mode = "named pipe"
case syscall.S_IFCHR:
mode = "char device"
case syscall.S_IFBLK:
mode = "block device"
default:
mode = "other"
}
tbl.RawSetString("mode", lua.LString(mode))
}
tbl.RawSetString("nlink", lua.LNumber(sys.Nlink))
tbl.RawSetString("uid", lua.LNumber(sys.Uid))
tbl.RawSetString("gid", lua.LNumber(sys.Gid))
tbl.RawSetString("rdev", lua.LNumber(sys.Rdev))
tbl.RawSetString("access", lua.LNumber(sys.Atimespec.Sec))
tbl.RawSetString("modification", lua.LNumber(sys.Mtimespec.Sec))
tbl.RawSetString("change", lua.LNumber(sys.Ctimespec.Sec))
tbl.RawSetString("size", lua.LNumber(sys.Size))
tbl.RawSetString("blocks", lua.LNumber(sys.Blocks))
tbl.RawSetString("blksize", lua.LNumber(sys.Blksize))
return nil
}