Files
isp-config-service/service/rqlite/internal/rarchive/targz.go
T
txix 7ee7b6749f
Create and publish a Docker image / build-and-push-image (push) Canceled after 0s
2025-12-01 16:45:09: merge [main:8101f9a8c84d0c8c7bd462ac374f4db79dbc5d21];
2025-12-01 16:45:09 +03:00

27 lines
429 B
Go

// nolint
package rarchive
import (
"compress/gzip"
"os"
)
// IsTarGzipFile checks if the file at the given path is a gzipped tarball
// by attempting to open it as such.
func IsTarGzipFile(path string) bool {
f, err := os.Open(path)
if err != nil {
return false
}
defer f.Close()
// Attempt to create a gzip reader
gzr, err := gzip.NewReader(f)
if err != nil {
return false
}
defer gzr.Close()
return true
}