代码拉取完成,页面将自动刷新
package input
import (
"os"
"github.com/elastic/beats/libbeat/logp"
)
const (
jsonErrorKey = "json_error"
)
type File struct {
File *os.File
FileInfo os.FileInfo
Path string
FileState *FileState
}
// NewFile create new File object
func NewFile(fileInfo os.FileInfo) File {
return File{
FileInfo: fileInfo,
}
}
// Check that the file isn't a symlink, mode is regular or file is nil
func (f *File) IsRegularFile() bool {
if f.File == nil {
logp.Critical("Harvester: BUG: f arg is nil")
return false
}
info, e := f.File.Stat()
if e != nil {
logp.Err("File check fault: stat error: %s", e.Error())
return false
}
if !info.Mode().IsRegular() {
logp.Warn("Harvester: not a regular file: %q %s", info.Mode(), info.Name())
return false
}
return true
}
// Checks if the two files are the same.
func (f *File) IsSameFile(f2 *File) bool {
return os.SameFile(f.FileInfo, f2.FileInfo)
}
// IsSameFile checks if the given File path corresponds with the FileInfo given
func IsSameFile(path string, info os.FileInfo) bool {
fileInfo, err := os.Stat(path)
if err != nil {
logp.Err("Error during file comparison: %s with %s - Error: %s", path, info.Name(), err)
return false
}
return os.SameFile(fileInfo, info)
}
func IsRegularFile(file *os.File) bool {
f := &File{File: file}
return f.IsRegularFile()
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。