// OpenFile find the mount of the given path and executes OpenFile
// on the corresponding filesystem.
// It wraps the resulting file to return the path inside mountfs on Name()
427537
func (fs MountFS) OpenFile(name string, flag int, perm os.FileMode) (vfs.File, error) {
	mount, innerPath := findMount(name, fs.mounts, fs.rootFS, string(fs.PathSeparator()))
	file, err := mount.OpenFile(innerPath, flag, perm)
	return innerFile{File: file, name: name}, err
}
27390
func openPackageFile(path string) (*PackageFile, error) {
	f, err := os.Open(path)
	if err != nil {
		return nil, err
	}
	defer f.Close()

	fi, err := f.Stat()
	if err != nil {
		return nil, err
	}

	p, err := ReadPackageFile(f)
	if err != nil {
		return nil, err
	}
	p.path = path
	p.fileSize = uint64(fi.Size())
	p.fileTime = fi.ModTime()
	return p, nil
}
598368
func OpenFile(path string) (Sections, error) {
	f, err := os.Open(path)
	if err != nil {
		return Sections{}, awserr.New(ErrCodeUnableToReadFile, "unable to open file", err)
	}
	defer f.Close()

	return Parse(f)
}
353679
func ReadFile(fs http.FileSystem, path string) ([]byte, error) {
	rc, err := fs.Open(path)
	if err != nil {
		return nil, err
	}
	defer rc.Close()
	return ioutil.ReadAll(rc)
}
988624
func (p *parserMixin) OpenFile(flag int, perm os.FileMode) (target **os.File) {
	target = new(*os.File)
	p.OpenFileVar(target, flag, perm)
	return
}
779101
func (c *Client) OpenFile(path string, f int) (*File, error) {
	return c.open(path, flags(f))
}
1036923
func (o osFileSystem) Open(name string) (http.File, error) {
	return o(name)
}
685063
func ReadFile(path string) ([]byte, error) {
	file, err := os.Open(path)
	if err != nil {
		return nil, err
	}
	defer Close(file)
	data, err := ioutil.ReadAll(file)
	if err != nil {
		return nil, err
	}
	return data, nil
}
960607
func (d *Dir) ReadFile(subPath string) ([]byte, error) {
	node, err := d.GetByPath(subPath)
	if err != nil {
		return nil, err
	}
	if node.IsDir() {
		return nil, fmt.Errorf("Use ReadFile on directory ")
	}
	var fileNode = node.(*File)
	return fileNode.GetData(), nil
}
787258
func (gr *GroupReader) openFile(index int) error {
	// Lock on Group to ensure that head doesn't move in the meanwhile.
	gr.Group.mtx.Lock()
	defer gr.Group.mtx.Unlock()

	if index > gr.Group.maxIndex {
		return io.EOF
	}

	curFilePath := filePathForIndex(gr.Head.Path, index, gr.Group.maxIndex)
	curFile, err := os.OpenFile(curFilePath, os.O_RDONLY|os.O_CREATE, autoFilePerms)
	if err != nil {
		return err
	}
	curReader := bufio.NewReader(curFile)

	// Update gr.cur*
	if gr.curFile != nil {
		gr.curFile.Close() // TODO return error?
	}
	gr.curIndex = index
	gr.curFile = curFile
	gr.curReader = curReader
	gr.curLine = nil
	return nil
}
46231
func (p *Pod) openFile(path string, flags int) (*os.File, error) {
	cdirfd, err := p.Fd()
	if err != nil {
		return nil, err
	}

	fd, err := syscall.Openat(cdirfd, path, flags, 0)
	if err != nil {
		return nil, err
	}

	return os.NewFile(uintptr(fd), path), nil
}
564753
func (fs RoFS) OpenFile(name string, flag int, perm os.FileMode) (File, error) {
	if flag&os.O_CREATE == os.O_CREATE {
		return nil, ErrReadOnly
	}
	if flag&os.O_APPEND == os.O_APPEND {
		return nil, ErrReadOnly
	}
	if flag&os.O_WRONLY == os.O_WRONLY {
		return nil, ErrReadOnly
	}
	f, err := fs.Filesystem.OpenFile(name, flag, perm)
	if err != nil {
		return ReadOnlyFile(f), err
	}
	return ReadOnlyFile(f), nil
}
1248946
func OpenFile(path string) error {
	logFilePath = path

	var err error
	logFile, err = os.OpenFile(logFilePath, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
	if err != nil {
		return err
	}

	SetOutput(logFile)
	return nil
}
795475
func (b *Browser) OpenFile(filename string, flag int, _ os.FileMode) (
	f billy.File, err error) {
	if b.tree == nil {
		return nil, errors.New("Empty repo")
	}

	if flag&os.O_CREATE != 0 {
		return nil, errors.New("browser can't create files")
	}

	return b.Open(filename)
}
897825
func ReadFile(path string) (map[string]string, error) {
	f, err := os.Open(path)
	if err != nil {
		return nil, err
	}
	defer f.Close()
	return Read(f)
}
1113217
func (l *httpFileSystem) OpenFile(filePath string) (io.ReadCloser, error) {
	if l.reader == nil {
		return nil, trace.BadParameter("missing reader")
	}

	return l.reader, nil
}
29260
func (s *Server) OpenFile(name string, mode int32) (File, error) {
	u := urlParse(name)

	if h, ok := s.schemes[u.Scheme]; ok {
		f, serr := h.Open(u, mode)
		if serr != os.ErrNotExist {
			return f, serr
		}
	}

	switch mode {
	case OpenModeReadOnly:
		return os.Open(filepath.Clean(name))
	case OpenModeWriteOnly:
		flag := os.O_WRONLY | os.O_CREATE | os.O_TRUNC
		return os.OpenFile(name, flag, 0600)
	default:
		return nil, &Status{
			Err:  fmt.Errorf("open mode(%d) not supported for file %q", mode, name),
			Code: StatusAccessDenied,
		}
	}
}