-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathsys_stat.go
49 lines (46 loc) · 1.73 KB
/
sys_stat.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
package libs
import (
"github.com/gotranspile/cxgo/runtime/csys"
"github.com/gotranspile/cxgo/types"
)
const (
sysStatH = "sys/stat.h"
)
func init() {
RegisterLibrary(sysStatH, func(c *Env) *Library {
intT := types.IntT(4)
strT := c.C().String()
timevalT := c.GetLibraryType(timeH, "timeval")
modeT := types.NamedTGo("mode_t", "csys.Mode", intT)
statT := types.NamedTGo("stat", "csys.StatRes", types.StructT([]*types.Field{
{Name: types.NewIdentGo("st_dev", "Dev", intT)},
{Name: types.NewIdentGo("st_ino", "Inode", intT)},
{Name: types.NewIdentGo("st_mode", "Mode", modeT)},
{Name: types.NewIdentGo("st_nlink", "Links", intT)},
{Name: types.NewIdentGo("st_uid", "UID", intT)},
{Name: types.NewIdentGo("st_gid", "GID", intT)},
{Name: types.NewIdentGo("st_rdev", "RDev", intT)},
{Name: types.NewIdentGo("st_size", "Size", types.UintT(8))},
{Name: types.NewIdentGo("st_atime", "ATime", timevalT)},
{Name: types.NewIdentGo("st_mtime", "MTime", timevalT)},
{Name: types.NewIdentGo("st_ctime", "CTime", timevalT)},
{Name: types.NewIdentGo("st_blksize", "BlockSize", intT)},
{Name: types.NewIdentGo("st_blocks", "Blocks", intT)},
}))
return &Library{
Imports: map[string]string{
"csys": RuntimePrefix + "csys",
},
Types: map[string]types.Type{
"mode_t": modeT,
"stat": statT,
},
Idents: map[string]*types.Ident{
"stat": c.NewIdent("stat", "csys.Stat", csys.Stat, c.FuncTT(intT, strT, c.PtrT(statT))),
"chmod": c.NewIdent("chmod", "csys.Chmod", csys.Chmod, c.FuncTT(intT, strT, modeT)),
"mkdir": c.NewIdent("mkdir", "csys.Mkdir", csys.Mkdir, c.FuncTT(intT, strT, modeT)),
"S_ISDIR": c.NewIdent("S_ISDIR", "csys.IsDir", csys.IsDir, c.FuncTT(intT, modeT)),
},
}
})
}