github.com/gotranspile/cxgo@v0.3.8-0.20240118201721-29871598a6a2/libs/sys_stat.go (about) 1 package libs 2 3 import ( 4 "github.com/gotranspile/cxgo/runtime/csys" 5 "github.com/gotranspile/cxgo/types" 6 ) 7 8 const ( 9 sysStatH = "sys/stat.h" 10 ) 11 12 func init() { 13 RegisterLibrary(sysStatH, func(c *Env) *Library { 14 intT := types.IntT(4) 15 strT := c.C().String() 16 timevalT := c.GetLibraryType(timeH, "timeval") 17 modeT := types.NamedTGo("mode_t", "csys.Mode", intT) 18 statT := types.NamedTGo("stat", "csys.StatRes", types.StructT([]*types.Field{ 19 {Name: types.NewIdentGo("st_dev", "Dev", intT)}, 20 {Name: types.NewIdentGo("st_ino", "Inode", intT)}, 21 {Name: types.NewIdentGo("st_mode", "Mode", modeT)}, 22 {Name: types.NewIdentGo("st_nlink", "Links", intT)}, 23 {Name: types.NewIdentGo("st_uid", "UID", intT)}, 24 {Name: types.NewIdentGo("st_gid", "GID", intT)}, 25 {Name: types.NewIdentGo("st_rdev", "RDev", intT)}, 26 {Name: types.NewIdentGo("st_size", "Size", types.UintT(8))}, 27 {Name: types.NewIdentGo("st_atime", "ATime", timevalT)}, 28 {Name: types.NewIdentGo("st_mtime", "MTime", timevalT)}, 29 {Name: types.NewIdentGo("st_ctime", "CTime", timevalT)}, 30 {Name: types.NewIdentGo("st_blksize", "BlockSize", intT)}, 31 {Name: types.NewIdentGo("st_blocks", "Blocks", intT)}, 32 })) 33 return &Library{ 34 Imports: map[string]string{ 35 "csys": RuntimePrefix + "csys", 36 }, 37 Types: map[string]types.Type{ 38 "mode_t": modeT, 39 "stat": statT, 40 }, 41 Idents: map[string]*types.Ident{ 42 "stat": c.NewIdent("stat", "csys.Stat", csys.Stat, c.FuncTT(intT, strT, c.PtrT(statT))), 43 "chmod": c.NewIdent("chmod", "csys.Chmod", csys.Chmod, c.FuncTT(intT, strT, modeT)), 44 "mkdir": c.NewIdent("mkdir", "csys.Mkdir", csys.Mkdir, c.FuncTT(intT, strT, modeT)), 45 "S_ISDIR": c.NewIdent("S_ISDIR", "csys.IsDir", csys.IsDir, c.FuncTT(intT, modeT)), 46 }, 47 } 48 }) 49 }