Exemple #1
0
// 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)
}
Exemple #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)
}