Beispiel #1
0
func NewFile(sysFile system.File, ignoreList []string) *File {
	path := sysFile.Path()
	exists, _ := sysFile.Exists()
	f := &File{
		Path:     path,
		Exists:   exists.(bool),
		Contains: []string{},
	}
	if !contains(ignoreList, "mode") {
		mode, _ := sysFile.Mode()
		f.Mode = mode.(string)
	}
	if !contains(ignoreList, "owner") {
		owner, _ := sysFile.Owner()
		f.Owner = owner.(string)
	}
	if !contains(ignoreList, "group") {
		group, _ := sysFile.Group()
		f.Group = group.(string)
	}
	if !contains(ignoreList, "linked-to") {
		linkedTo, _ := sysFile.LinkedTo()
		f.LinkedTo = linkedTo.(string)
	}
	if !contains(ignoreList, "filetype") {
		filetype, _ := sysFile.Filetype()
		f.Filetype = filetype.(string)
	}
	return f
}
Beispiel #2
0
func NewFile(sysFile system.File) *File {
	path := sysFile.Path()
	mode, _ := sysFile.Mode()
	owner, _ := sysFile.Owner()
	group, _ := sysFile.Group()
	linkedTo, _ := sysFile.LinkedTo()
	filetype, _ := sysFile.Filetype()
	exists, _ := sysFile.Exists()
	return &File{
		Path:     path,
		Mode:     mode.(string),
		Owner:    owner.(string),
		Group:    group.(string),
		LinkedTo: linkedTo.(string),
		Filetype: filetype.(string),
		Contains: []string{},
		Exists:   exists.(bool),
	}
}
Beispiel #3
0
func NewFile(sysFile system.File, config util.Config) (*File, error) {
	path := sysFile.Path()
	exists, _ := sysFile.Exists()
	f := &File{
		Path:     path,
		Exists:   exists,
		Contains: []string{},
	}
	if !contains(config.IgnoreList, "mode") {
		if mode, err := sysFile.Mode(); err == nil {
			f.Mode = mode
		}
	}
	if !contains(config.IgnoreList, "owner") {
		if owner, err := sysFile.Owner(); err == nil {
			f.Owner = owner
		}
	}
	if !contains(config.IgnoreList, "group") {
		if group, err := sysFile.Group(); err == nil {
			f.Group = group
		}
	}
	if !contains(config.IgnoreList, "linked-to") {
		if linkedTo, err := sysFile.LinkedTo(); err == nil {
			f.LinkedTo = linkedTo
		}
	}
	if !contains(config.IgnoreList, "filetype") {
		if filetype, err := sysFile.Filetype(); err == nil {
			f.Filetype = filetype
		}
	}
	if !contains(config.IgnoreList, "size") {
		if size, err := sysFile.Size(); err == nil {
			f.Size = size
		}
	}
	return f, nil
}