github.com/slspeek/camlistore_namedsearch@v0.0.0-20140519202248-ed6f70f7721a/pkg/schema/schema_posix.go (about)

     1  //+build linux darwin netbsd freebsd openbsd
     2  //+build !appengine
     3  
     4  package schema
     5  
     6  import (
     7  	"os"
     8  	"syscall"
     9  )
    10  
    11  func init() {
    12  	populateSchemaStat = append(populateSchemaStat, populateSchemaUnix)
    13  }
    14  
    15  func populateSchemaUnix(m map[string]interface{}, fi os.FileInfo) {
    16  	st, ok := fi.Sys().(*syscall.Stat_t)
    17  	if !ok {
    18  		return
    19  	}
    20  	m["unixOwnerId"] = st.Uid
    21  	if user := getUserFromUid(int(st.Uid)); user != "" {
    22  		m["unixOwner"] = user
    23  	}
    24  	m["unixGroupId"] = st.Gid
    25  	if group := getGroupFromGid(int(st.Gid)); group != "" {
    26  		m["unixGroup"] = group
    27  	}
    28  }