// File writes a file to the push package.
//
// NOTE: Name is a relative path. Only forward slashes are allowed.
497804
func (p *Package) File(name, src string) {
	if p.err != nil {
		return
	}

	f, err := os.Open(src)
	if err != nil {
		p.err = err
		return
	}
	defer f.Close()
	p.Copy(name, f)
}
734611
func (r *Response) File(path string) error {
	abspath, err := filepath.Abs(path)

	if err != nil {
		return err
	}

	if !r.fileExists(abspath) {
		return err
	}

	r.file = abspath
	return nil
}
346308
func (f *File) Save() error {
	if f.Path == "" {
		return fmt.Errorf("no path defined for file, consider File.WriteTo or File.Write")
	}
	return f.SaveAs(f.Path)
}
1013216
func (s *FileSet) File(p Pos) (f *File) {
	if p != NoPos {
		s.mutex.RLock()
		f = s.file(p)
		s.mutex.RUnlock()
	}
	return
}
889850
func (p *PollSet) File(f *os.File, events EventSet) (index int) {
	return p.Fd(f.Fd(), events)
}
1134148
func (f *File) Serialize(w io.Writer) error {
	_, err := iotools.WriteTracker(w, func(w io.Writer) error {
		needsNLs := 0
		maybeAddNL := func() {
			if needsNLs > 0 {
				w.Write(bytes.Repeat([]byte("\n"), needsNLs))
				needsNLs = 0
			}
		}

		if f.ServiceURL != "" {
			maybeAddNL()
			fmt.Fprintf(w, "$ServiceURL %s", f.ServiceURL)
			needsNLs = 1
		}
		if f.ParanoidMode != "" && f.ParanoidMode != deployer.NotParanoid {
			maybeAddNL()
			fmt.Fprintf(w, "$ParanoidMode %s", f.ParanoidMode)
			needsNLs = 1
		}
		if f.ResolvedVersions != "" {
			maybeAddNL()
			fmt.Fprintf(w, "$ResolvedVersions %s", f.ResolvedVersions)
			needsNLs = 1
		}

		if needsNLs != 0 {
			needsNLs += 1 // new line separator if any of $Directives were used
		}

		if len(f.VerifyPlatforms) > 0 {
			for _, plat := range f.VerifyPlatforms {
				maybeAddNL()

				fmt.Fprintf(w, "$VerifiedPlatform %s", plat.String())
				needsNLs = 1
			}

			needsNLs = 2
		}

		keys := make(sort.StringSlice, 0, len(f.PackagesBySubdir))
		for k := range f.PackagesBySubdir {
			keys = append(keys, k)
		}
		keys.Sort()

		for _, k := range keys {
			maybeAddNL()
			if k != "" {
				fmt.Fprintf(w, "@Subdir %s", k)
				needsNLs = 1
			}

			pkgs := f.PackagesBySubdir[k]
			pkgsSort := make(PackageSlice, len(pkgs))
			maxLength := 0
			for i, pkg := range pkgs {
				pkgsSort[i] = pkg
				if l := len(pkg.PackageTemplate); l > maxLength {
					maxLength = l
				}
			}
			sort.Sort(pkgsSort)

			for _, p := range pkgsSort {
				maybeAddNL()
				fmt.Fprintf(w, "%-*s %s", maxLength+1, p.PackageTemplate, p.UnresolvedVersion)
				needsNLs = 1
			}
			needsNLs++
		}

		// We only ever want to end the file with 1 newline.
		if needsNLs > 0 {
			needsNLs = 1
		}
		maybeAddNL()
		return nil
	})
	return err
}
682988
func (w *File) Write(p []byte) (int, error) {
	if w.Closed() {
		return 0, AlreadyClosed
	}

	w.hasher.Write(p)
	return w.tempFile.Write(p)
}
808605
func (t *Tree) File(path string) (*File, error) {
	e, err := t.FindEntry(path)
	if err != nil {
		return nil, ErrFileNotFound
	}

	blob, err := GetBlob(t.s, e.Hash)
	if err != nil {
		if err == plumbing.ErrObjectNotFound {
			return nil, ErrFileNotFound
		}
		return nil, err
	}

	return NewFile(path, e.Mode, blob), nil
}
711893
func (e *Echo) File(path, file string, m ...MiddlewareFunc) *Route {
	return e.file(path, file, e.GET, m...)
}
505083
func (s *Store) Path(i interface{}) string {
	name := strings.ToLower(reflect.TypeOf(i).Elem().Name())
	return filepath.Join(s.Base, name+".yaml")
}
1095150
func (s Store) WriteFile(filename string) error {
	buf, err := s.Bytes()
	if err != nil {
		return err
	}

	return ioutil.WriteFile(filename, buf, 0600)
}
561946
func (c Context) Files(name string) ([]string, error) {
	dir, err := c.Root.Open(path.Clean(name))
	if err != nil {
		return nil, err
	}
	defer dir.Close()

	stat, err := dir.Stat()
	if err != nil {
		return nil, err
	}
	if !stat.IsDir() {
		return nil, fmt.Errorf("%v is not a directory", name)
	}

	dirInfo, err := dir.Readdir(0)
	if err != nil {
		return nil, err
	}

	names := make([]string, len(dirInfo))
	for i, fileInfo := range dirInfo {
		names[i] = fileInfo.Name()
	}

	return names, nil
}
1268763
func File() string {
	f := os.Getenv("CSEARCHINDEX")
	if f != "" {
		return f
	}
	var home string
	home = os.Getenv("HOME")
	if runtime.GOOS == "windows" && home == "" {
		home = os.Getenv("USERPROFILE")
	}
	return filepath.Clean(home + "/.csearchindex")
}
73438
func File(file, prefix string) bool {
	// special case for current directory completion
	if file == "./" && (prefix == "." || prefix == "") {
		return true
	}
	if prefix == "." && strings.HasPrefix(file, ".") {
		return true
	}

	file = strings.TrimPrefix(file, "./")
	prefix = strings.TrimPrefix(prefix, "./")

	return strings.HasPrefix(file, prefix)
}
166315
func Files(srcPath string) ([]models.Path, error) {
	srcPath, err := filepath.Abs(srcPath)
	if err != nil {
		return nil, fmt.Errorf("filepath.Abs: %v\n", err)
	}
	var fi os.FileInfo
	if fi, err = os.Stat(srcPath); err != nil {
		return nil, fmt.Errorf("os.Stat: %v\n", err)
	}
	if fi.IsDir() {
		return dirFiles(srcPath)
	}
	return file(srcPath)
}
692375
func (f *File) Name() string {
	name := strings.Split(f.fileID, ";")[0]
	return strings.ToLower(name)
}
1237910
func (f *Fibre) File(p, file string) {
	f.Get(p, func(c *Context) error {
		return c.File(file)
	})
}