mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-06-29 16:20:46 +00:00
Adds the ability to read gzip-tar file for the taxonomy dump
This commit is contained in:
20
pkg/obiutils/tar.go
Normal file
20
pkg/obiutils/tar.go
Normal file
@ -0,0 +1,20 @@
|
||||
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)
|
||||
}
|
Reference in New Issue
Block a user