本文整理匯總了Golang中github.com/milosgajdos83/servpeek/resource.Filer.Info方法的典型用法代碼示例。如果您正苦於以下問題:Golang Filer.Info方法的具體用法?Golang Filer.Info怎麽用?Golang Filer.Info使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/milosgajdos83/servpeek/resource.Filer
的用法示例。
在下文中一共展示了Filer.Info方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ModTimeAfter
// ModTimeAfter checks if the provided file modification time is older than the one passed in as paramter
// It returns error if os.Stat returns error
func ModTimeAfter(f resource.Filer, mtime time.Time) error {
fi, err := f.Info()
if err != nil {
return err
}
if fi.ModTime().After(mtime) {
return nil
}
return fmt.Errorf("%s modification time is bigger than %s", f, mtime)
}
示例2: Size
// Size checks if the provided file byte size is the same as the one passed in as paramter
// It returns error if os.Stat returns error
func Size(f resource.Filer, size int64) error {
fi, err := f.Info()
if err != nil {
return err
}
if fi.Size() == size {
return nil
}
return fmt.Errorf("%s size is different from %d", f, size)
}
示例3: IsGrupedInto
// IsGrupedInto checks if the provided file is owned by groupname group
// It returns an error if os.Stat returns error
func IsGrupedInto(f resource.Filer, groupname string) error {
fi, err := f.Info()
if err != nil {
return err
}
gid, err := utils.RoleToID("group", groupname)
if err != nil {
return err
}
return isTrueOrError(fi.Sys().(*syscall.Stat_t).Gid == uint32(gid), fmt.Errorf("%s file is not grouped to %s", f, groupname))
}
示例4: IsOwnedBy
// IsOwnedBy checks if the provided file is owned by username user
// It returns an error if os.Stat returns error
func IsOwnedBy(f resource.Filer, username string) error {
fi, err := f.Info()
if err != nil {
return nil
}
uid, err := utils.RoleToID("user", username)
if err != nil {
return err
}
return isTrueOrError(fi.Sys().(*syscall.Stat_t).Uid == uint32(uid), fmt.Errorf("%s file is not owned by %s", f, username))
}
示例5: IsMode
// IsMode checks if the provided file has the same mode as the one passed in via paramter
// It returns error if os.Stat returns error
func IsMode(f resource.Filer, mode os.FileMode) error {
fi, err := f.Info()
if err != nil {
return err
}
if verboseMode, ok := verboseNames[mode]; ok {
err = fmt.Errorf("%s file is not a %s", f, verboseMode)
} else {
err = fmt.Errorf("%s file is not mode %v", f, mode)
}
return isTrueOrError(fi.Mode()&mode != 0, err)
}