// open tries to open a file.
963692
func (pl ProfileList) open(ctx context.Context, oc *openContext, path []string) (dokan.File, dokan.CreateStatus, error) {
	if len(path) == 0 {
		return oc.returnDirNoCleanup(ProfileList{})
	}
	if len(path) > 1 || !libfs.IsSupportedProfileName(path[0]) {
		return nil, 0, dokan.ErrObjectNameNotFound
	}
	f := libfs.ProfileGet(path[0])
	if f == nil {
		return nil, 0, dokan.ErrObjectNameNotFound
	}
	return oc.returnFileNoCleanup(&SpecialReadFile{read: f, fs: pl.fs})
}
1212010
func (lfs localFileSystem) Open(fn string) (ReadCloser, error) {
	file, err := villa.Path(fn).Open()
	if err != nil {
		return nil, err
	}

	return BufferedFileReader{
		file:   file,
		Reader: bufio.NewReader(file),
	}, nil
}
225698
func (t *TraceFS) Open(ctx context.Context, path string) (f *File, err error) {
	if tr, ok := trace.FromContext(ctx); ok {
		tr.LazyPrintf("%v: open: %v", t.name, path)
		defer func() {
			if err != nil {
				tr.LazyPrintf("%v: error: %v", t.name, err)
				tr.SetError()
			}
		}()
	}
	return t.fs.Open(ctx, path)
}
716667
func (tlf *TLF) open(ctx context.Context, oc *openContext, path []string) (
	dokan.File, dokan.CreateStatus, error) {
	if len(path) == 0 {
		if err := oc.ReturningDirAllowed(); err != nil {
			return nil, 0, err
		}
		tlf.refcount.Increase()
		return tlf, dokan.ExistingDir, nil
	}

	mode := libkbfs.ReadMode
	if oc.isCreation() {
		mode = libkbfs.WriteMode
	}
	// If it is a creation then we need the dir for real.
	dir, exitEarly, err :=
		tlf.loadDirHelper(
			ctx, "open", mode, data.MasterBranch, !oc.isCreation())
	if err != nil {
		return nil, 0, err
	}
	if exitEarly {
		specialNode := handleTLFSpecialFile(lastStr(path), tlf.folder)
		if specialNode != nil {
			return specialNode, dokan.ExistingFile, nil
		}

		return nil, 0, dokan.ErrObjectNameNotFound
	}

	branch, isArchivedBranch := libfs.BranchNameFromArchiveRefDir(path[0])
	if isArchivedBranch {
		archivedTLF := newTLF(
			tlf.folder.list, tlf.folder.h, tlf.folder.hPreferredName)
		_, _, err := archivedTLF.loadArchivedDir(ctx, "open", branch)
		if err != nil {
			return nil, 0, err
		}
		return archivedTLF.open(ctx, oc, path[1:])
	}

	linkTarget, isArchivedTimeLink, err := libfs.LinkTargetFromTimeString(
		ctx, tlf.folder.fs.config, tlf.folder.h, path[0])
	if err != nil {
		return nil, 0, err
	}
	if isArchivedTimeLink {
		if len(path) == 1 && oc.isOpenReparsePoint() {
			// TODO handle dir/non-dir here, semantics?
			return &Alias{canon: linkTarget}, dokan.ExistingDir, nil
		}
		path[0] = linkTarget
		return tlf.open(ctx, oc, path)
	}

	_, isRelTimeLink, err := libfs.FileDataFromRelativeTimeString(
		ctx, tlf.folder.fs.config, tlf.folder.h, path[0])
	if err != nil {
		return nil, 0, err
	}
	if isRelTimeLink {
		return NewArchiveRelTimeFile(tlf.folder.fs, tlf.folder.h, path[0]),
			dokan.ExistingFile, nil
	}

	return dir.open(ctx, oc, path)
}
664334
func (s ErrCountFS) Open(ctx context.Context, path string) (*File, error) {
	f, err := s.fs.Open(ctx, path)
	if err == s.err {
		s.status.Add("open.count", 1)
	}
	s.status.Add("open.total", 1)
	return f, err
}
201584
func Open(path string) (*File, error) {
	f, err := os.Open(path)
	if err != nil {
		return nil, err
	}
	stat, err := f.Stat()
	if err != nil {
		f.Close()
		return nil, err
	}

	contentType, err := api.DetectContentType(f.Name(), f)
	if err != nil {
		return nil, err
	}

	return &File{
		ReadCloser: f,
		ManifestEntry: api.ManifestEntry{
			ContentType: contentType,
			Mode:        int64(stat.Mode()),
			Size:        stat.Size(),
			ModTime:     stat.ModTime(),
		},
	}, nil
}
264928
func Open(path string, flag int, perm os.FileMode) (*os.File, error) {
	return os.OpenFile(path, flag, perm)
}
706228
func (m *mem) Open(_ context.Context, path string) (*File, error) {
	m.RLock()
	f, ok := m.data[path]
	m.RUnlock()

	if ok {
		return &File{
			ReadCloser: f.readCloser(),
			Name:       f.name,
			ModTime:    f.modTime,
			Size:       f.size(),
		}, nil
	}
	return nil, &notExistError{
		Path: path,
	}
}
438487
func (f *IndexFile) Open() error {
	defer func() {
		if err := recover(); err != nil {
			err = fmt.Errorf("[Index file: %s] %v", f.path, err)
			panic(err)
		}
	}()

	// Extract identifier from path name.
	f.id, f.level = ParseFilename(f.Path())

	data, err := mmap.Map(f.Path(), 0)
	if err != nil {
		return err
	}

	return f.UnmarshalBinary(data)
}
991810
func (e *Engine) Open() error {
	e.initTrackers()

	if err := os.MkdirAll(e.path, 0777); err != nil {
		return err
	}

	if err := e.cleanup(); err != nil {
		return err
	}

	if err := e.WAL.Open(); err != nil {
		return err
	}

	if err := e.FileStore.Open(); err != nil {
		return err
	}

	if err := e.reloadCache(); err != nil {
		return err
	}

	e.Compactor.Open()

	if e.enableCompactionsOnOpen {
		e.SetCompactionsEnabled(true)
	}

	return nil
}
272822
func Open(file string) (*Reader, error) {
	reader, err := maxminddb.Open(file)
	if err != nil {
		return nil, err
	}
	dbType, err := getDBType(reader)
	return &Reader{reader, dbType}, err
}
1062914
func Open(logFile string) error {
	f, err := os.Create(logFile)
	if err != nil {
		return err
	}
	globalTee.f = f
	return nil
}
248992
func Open(listener func(*vecty.Event)) *vecty.EventListener {
	return &vecty.EventListener{Name: "open", Listener: listener}
}
1193232
func (h *fs) Open(filename string) (io.ReadCloser, error) {
	return os.Open(filename)
}
961608
func (f *FileSystem) Open(p string) (http.File, error) {
	p = path.Clean(p)

	if len(f.LocalPath) != 0 {
		return http.Dir(f.LocalPath).Open(p)
	}

	if fi, ok := f.Files[p]; ok {
		if !fi.IsDir() {
			// Make a copy for reading
			ret := fi
			ret.buf = bytes.NewReader(ret.Data)

			return ret, nil
		}

		return fi, nil
	}

	return nil, os.ErrNotExist
}
1361649
func (b *Browser) Open(filename string) (f billy.File, err error) {
	if b.tree == nil {
		return nil, errors.New("Empty repo")
	}

	defer translateGitError(&err)
	for i := 0; i < maxSymlinkLevels; i++ {
		fi, err := b.Lstat(filename)
		if err != nil {
			return nil, err
		}

		// Check if this is a submodule.
		if sfi, ok := fi.(*submoduleFileInfo); ok {
			return sfi.sf, nil
		}

		// If it's not a symlink, we can return right away.
		if fi.Mode()&os.ModeSymlink == 0 {
			f, err := b.tree.File(filename)
			if err != nil {
				return nil, err
			}
			return newBrowserFile(f)
		}

		filename, err = b.followSymlink(filename)
		if err != nil {
			return nil, err
		}
	}
	return nil, errors.New("cannot resolve deep symlink chain")
}
886505
func (l *httpFileSystemLoader) Open(name string) (io.ReadCloser, error) {
	if l.fs == nil {
		return nil, &os.PathError{Op: "open", Path: name, Err: os.ErrNotExist}
	}
	return l.fs.Open(name)
}