mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-06-29 16:20:46 +00:00
21 lines
346 B
Go
21 lines
346 B
Go
package obiutils
|
|
|
|
import (
|
|
"archive/tar"
|
|
"fmt"
|
|
)
|
|
|
|
func TarFileReader(file *Reader, path string) (*tar.Reader, error) {
|
|
tarfile := tar.NewReader(file)
|
|
header, err := tarfile.Next()
|
|
|
|
for err == nil {
|
|
if header.Name == path {
|
|
return tarfile, nil
|
|
}
|
|
header, err = tarfile.Next()
|
|
}
|
|
|
|
return nil, fmt.Errorf("file not found: %s", path)
|
|
}
|