예제 #1
0
파일: extractor.go 프로젝트: benjyw/kythe
// readFileData fetches the contents of the file at path and returns a FileData
// message populated with its content, path, and digest.
func (c *Config) readFileData(ctx context.Context, path string) (*apb.FileData, error) {
	f, err := c.openFile(ctx, path)
	if err != nil {
		return nil, err
	}
	defer f.Close()
	return kindex.FileData(path, f)
}
예제 #2
0
// readFile fetches the contents of the file at path and returns a FileData
// message populated with its content, path, and digest.
func (c *Config) readFile(ctx context.Context, path string) (*apb.FileData, error) {
	open := c.OpenRead
	if open == nil {
		open = osOpen
	}
	f, err := open(ctx, path)
	if err != nil {
		return nil, err
	}
	defer f.Close()
	return kindex.FileData(path, f)
}