// getFile ensures that the store's file handle is valid, opening
// the file if needed. If file needs to be opened, the store's writer
// is set to either the bare file or the buffered writer (based on
// store's configuration).
351969
func (ss *FileSubStore) lockFile() error {
	wasOpened, err := ss.fm.lockFile(ss.file)
	if err != nil {
		return err
	}
	// If file was not opened, we need to reset ss.writer
	if !wasOpened {
		if ss.bw != nil {
			ss.writer = ss.bw.createNewWriter(ss.file.handle)
		} else {
			ss.writer = ss.file.handle
		}
	}
	return nil
}
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
}
950919
func (wav Reader) GetFile() File {
	return File{
		SampleRate:      wav.chunkFmt.SampleRate,
		Channels:        wav.chunkFmt.NumChannels,
		SignificantBits: wav.chunkFmt.BitsPerSample,
		BytesPerSecond:  wav.chunkFmt.BytesPerSec,
		AudioFormat:     wav.chunkFmt.AudioFormat,
		NumberOfSamples: wav.numSamples,
		SoundSize:       wav.dataBlocSize,
		Duration:        wav.duration,
		Canonical:       wav.canonical && !wav.extraChunk,
	}
}
290976
func (d *S3Driver) GetFile(path string, position int64) (io.ReadCloser, bool) {
	svc := d.s3service()

	path = strings.TrimPrefix(path, "/")

	params := &s3.GetObjectInput{
		Bucket: aws.String(d.AWSBucketName), // Required
		Key:    aws.String(path),            // Required
	}
	resp, err := svc.GetObject(params)

	if awserr := aws.Error(err); awserr != nil {
		// A service error occurred.
		fmt.Println("Error:", awserr.Code, awserr.Message)
		return nil, false
	} else if err != nil {
		// A non-service error occurred.
		panic(err)
		return nil, false
	}

	return resp.Body, true
}
921588
func (api *Client) GetFile(downloadURL string, writer io.Writer) error {
	return downloadFile(api.httpclient, api.token, downloadURL, writer, api)
}
322327
func ReadFile(filename string) (*File, error) {
	fin, err := os.Open(filename)
	if err != nil {
		return nil, err
	}
	defer fin.Close()

	f := new(File)
	f.Root, err = Parse(fin)
	if err != nil {
		return nil, err
	}

	return f, nil
}
20770
func (f *GFile) GetPath() string {
	return gostring(gstring(C.g_file_get_path(f.GFile)))
}
926661
func (s *Store) Get(ctx context.Context, name string) (store.Secret, error) {
	p := s.passfile(name)

	ciphertext, err := s.storage.Get(ctx, p)
	if err != nil {
		out.Debug(ctx, "File %s not found: %s", p, err)
		return nil, store.ErrNotFound
	}

	content, err := s.crypto.Decrypt(ctx, ciphertext)
	if err != nil {
		out.Debug(ctx, "Decryption failed: %s", err)
		return nil, store.ErrDecrypt
	}

	sec, err := secret.Parse(content)
	if err != nil {
		out.Debug(ctx, "Failed to parse YAML: %s", err)
	}
	return sec, nil
}
215381
func (f *FilesystemStore) Get(name string) ([]byte, error) {
	p, err := f.getPath(name)
	if err != nil {
		return nil, err
	}
	meta, err := ioutil.ReadFile(p)
	if err != nil {
		if os.IsNotExist(err) {
			err = ErrMetaNotFound{Resource: name}
		}
		return nil, err
	}
	return meta, nil
}
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
}
1050863
func OpenFile(filename string) (*File, error) {
	file, err := os.Open(filename)
	if err != nil {
		return nil, err
	}
	defer file.Close()
	f, err := OpenReader(file)
	if err != nil {
		return nil, err
	}
	f.Path = filename
	return f, nil
}
187970
func ReadFile(path string) ([]byte, error) {
	f, err := FS.OpenFile(CTX, path, os.O_RDONLY, 0644)
	if err != nil {
		return nil, err
	}

	buf := bytes.NewBuffer(make([]byte, 0, bytes.MinRead))

	// If the buffer overflows, we will get bytes.ErrTooLarge.
	// Return that as an error. Any other panic remains.
	defer func() {
		e := recover()
		if e == nil {
			return
		}
		if panicErr, ok := e.(error); ok && panicErr == bytes.ErrTooLarge {
			err = panicErr
		} else {
			panic(e)
		}
	}()
	_, err = buf.ReadFrom(f)
	return buf.Bytes(), err
}
825133
func ReadFile(filename string) ([]byte, error) {
	buf, err := ioutil_base.ReadFile(filename)
	if err != nil {
		return nil, errors.Wrapf(err, "failed to read file %q", filename)
	}
	return buf, nil
}
284226
func (a Afero) ReadFile(filename string) ([]byte, error) {
	return ReadFile(a.Fs, filename)
}
241106
func (d *FileDepot) GetFile(tag *Tag) (*File, error) {
	if err := d.check(tag); err != nil {
		return nil, err
	}
	fi, err := os.Stat(d.path(tag.name))
	if err != nil {
		return nil, err
	}
	b, err := ioutil.ReadFile(d.path(tag.name))
	return &File{fi, b}, err
}
453118
func (fsh *Handler) ReadFile(file string) ([]byte, error) {
	return ioutil.ReadFile(file)
}
1337268
func (f File) LoadFile(file string) (err error) {
	in, err := os.Open(file)
	if err != nil {
		return
	}
	defer in.Close()
	return f.Load(in)
}