// touchFile does what is says on the tin, it touches a file
329080
func touchFile(p string) error {
	_, err := os.Lstat(p)
	if err == nil {
		return nil
	}

	if !os.IsNotExist(err) {
		return fmt.Errorf("error getting state of file %q: %v", p, err)
	}

	f, err := os.Create(p)
	if err != nil {
		return fmt.Errorf("error touching file %q: %v", p, err)
	}

	if err = f.Close(); err != nil {
		return fmt.Errorf("error closing touched file %q: %v", p, err)
	}

	return nil
}
1158445
func OpenFile(path string) (*os.File, error) {
	newPath, err := NormalizePath(path)
	if err != nil {
		return nil, trace.Wrap(err)
	}
	fi, err := os.Stat(newPath)
	if err != nil {
		return nil, trace.ConvertSystemError(err)
	}
	if fi.IsDir() {
		return nil, trace.BadParameter("%v is not a file", path)
	}
	f, err := os.Open(newPath)
	if err != nil {
		return nil, trace.ConvertSystemError(err)
	}
	return f, nil
}
468507
func deleteFile(filename string) error {
	if fileExists(filename) {
		return os.Remove(filename)
	}
	return nil
}
810025
func (d *Data) AddFile(key string, file *multipart.FileHeader) {
	d.Files[key] = file
}
702505
func (fs OsFS) OpenFile(name string, flag int, perm os.FileMode) (File, error) {
	return os.OpenFile(name, flag, perm)
}
672715
func (c *Clamd) ScanFile(path string) (chan *ScanResult, error) {
	command := fmt.Sprintf("SCAN %s", path)
	ch, err := c.simpleCommand(command)
	return ch, err
}
1269574
func ToOsFile(f File) *os.File {
	if osFile, ok := f.(*os.File); ok {
		return osFile
	}
	if osFile2, ok := f.(OsFile); ok {
		return osFile2.OsFile()
	}
	return nil
}
1180318
func NewFile(fd uintptr, name string) *os.File {
	return newfile(fd, name)
}
49388
func (cf cFiler) CurrentFile(file string) (protocol.FileInfo, bool) {
	return cf.Get(protocol.LocalDeviceID, file)
}
121017
func (gr *GoReq) SendFile(paramName, filePath string) *GoReq {
	gr.FileParam = paramName
	gr.FilePath = filePath
	return gr
}
884585
func OpenFile(filename string) (apk *Apk, err error) {
	f, err := os.Open(filename)
	if err != nil {
		return nil, err
	}
	defer func() {
		if err != nil {
			f.Close()
		}
	}()
	fi, err := f.Stat()
	if err != nil {
		return nil, err
	}
	apk, err = OpenZipReader(f, fi.Size())
	if err != nil {
		return nil, err
	}
	apk.f = f
	return
}
243844
func tempfile() (*os.File, error) {
	f, err := ioutil.TempFile("", "rqlilte-snap-")
	if err != nil {
		return nil, err
	}
	return f, nil
}
938795
func DoFile(l *State, fileName string) error {
	if err := LoadFile(l, fileName, ""); err != nil {
		return err
	}
	return l.ProtectedCall(0, MultipleReturns, 0)
}
1274850
func (si *SegmentInfo) AddFile(file string) {
	si.checkFileNames(map[string]bool{file: true})
	si.files[file] = true
}
682527
func (a *AttributeDefinition) IsFile(attName string) bool {
	if !a.Type.IsObject() {
		panic("checking pointer field on non-object") // bug
	}
	att := a.Type.ToObject()[attName]
	if att == nil {
		return false
	}
	return att.Type.Kind() == FileKind
}
451563
func CloseFile(f *os.File) error {
	atomic.AddUint64(&fileCount, ^uint64(0)) // decrement
	return f.Close()
}
1144620
func LoadFile(data string) (file *File, err error) {
	file = &File{}
	if err = proto.UnmarshalTextML(data, file); err != nil {
		return
	}
	err = file.Normalize()
	return
}