// openFile is the mobile-specific way of opening a file
423631
func openFile(url string) (io.ReadCloser, error) {
	usedUrl := url
	if strings.HasPrefix(url, "assets/") {
		usedUrl = usedUrl[7:]
	}

	return asset.Open(usedUrl)
}
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
}
2957
func OpenLockFile(name string, perm os.FileMode) (lock *LockFile, err error) {
	var file *os.File
	if file, err = os.OpenFile(name, os.O_RDWR|os.O_CREATE, perm); err == nil {
		lock = &LockFile{file}
	}
	return
}
746586
func ExpandFile(dest, src string) error {
	h, err := os.Open(src)
	if err != nil {
		return err
	}
	defer h.Close()
	return Expand(dest, h)
}
789257
func (r *Rar) OpenFile(filename string) error {
	if r.rr != nil {
		return fmt.Errorf("rar archive is already open for reading")
	}
	var err error
	r.rc, err = rardecode.OpenReader(filename, r.Password)
	if err != nil {
		return err
	}
	r.rr = &r.rc.Reader
	return nil
}
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,
	}
}
460296
func (t *File) reopenFile() error {
	t.fmu.Lock()
	defer t.fmu.Unlock()

	if t.file != nil {
		if err := t.file.Close(); err != nil {
			return err
		}
	}

	var err error
	t.file, err = os.OpenFile(t.filename, os.O_RDONLY, 0)
	switch {
	case os.IsNotExist(err):
		t.file = nil
	default:
		return err
	}

	return nil
}
1338732
func openTempFile(prefix string, suffix string, mode os.FileMode) (string, *os.File, error) {
	filename, err := RandomID(prefix)
	if err != nil {
		return "", nil, err
	}
	if suffix != "" {
		filename = filename + suffix
	}
	flags := os.O_WRONLY | os.O_CREATE | os.O_EXCL
	if mode == 0 {
		mode = 0600
	}
	file, err := os.OpenFile(filename, flags, mode)
	return filename, file, err
}
742585
func OpenFile(filename string) (*File, error) {
	content, err := readFile(filename)
	if err != nil {
		return nil, err
	}

	f := CreateFile(filepath.Base(filename), content)

	return f, nil
}
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)
}
586788
func (fs *NativeFilesystem) OpenFile(name string, flag int, perm os.FileMode) (file File, err error) {
	return os.OpenFile(name, flag, perm)
}
861443
func openFile(name string) (*tar.Reader, *os.File, error) {
	f, err := os.Open(name)
	if err != nil {
		return nil, nil, err
	}

	gr, err := gzip.NewReader(f)
	if err != nil {
		f.Close()
		return nil, nil, err
	}

	return tar.NewReader(gr), f, 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)
}
1373507
func (c *Client) Open(name string) (*FileReader, error) {
	info, err := c.getFileInfo(name)
	if err != nil {
		return nil, &os.PathError{"open", name, interpretException(err)}
	}

	return &FileReader{
		client: c,
		name:   name,
		info:   info,
		closed: false,
	}, nil
}
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)
}
803576
func ReadFile(ctx context.Context, fs FileSystem, path string) ([]byte, error) {
	rc, err := fs.Open(ctx, path)
	if err != nil {
		return nil, err
	}
	defer rc.Close()
	return ioutil.ReadAll(rc)
}
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)
}