// rangeReader calls ioutil.ReadAll on the given byte range [start, n). It uses // optimizations for different kinds of VFSs. func rangeReader(fs rwvfs.FileSystem, name string, f io.ReadSeeker, start, n int64) (io.Reader, error) { if fs, ok := fs.(rwvfs.FetcherOpener); ok { // Clone f so we can parallelize it. var err error f, err = fs.OpenFetcher(name) if err != nil { return nil, err } if err := f.(rwvfs.Fetcher).Fetch(start, start+n); err != nil { return nil, err } } if _, err := f.Seek(start, 0); err != nil { return nil, err } return f, nil }