MCPcopy
hub / github.com/slimtoolkit/slim / IsTarFile

Function IsTarFile

pkg/util/fsutil/fsutil.go:259–275  ·  view source on GitHub ↗

IsTarFile returns true if the target file system object is a tar archive

(target string)

Source from the content-addressed store, hash-verified

257
258// IsTarFile returns true if the target file system object is a tar archive
259func IsTarFile(target string) bool {
260 tf, err := os.Open(target)
261 if err != nil {
262 log.Debugf("fsutil.IsTarFile(%s): error - %v", target, err)
263 return false
264 }
265
266 defer tf.Close()
267 tr := tar.NewReader(tf)
268 _, err = tr.Next()
269 if err != nil {
270 log.Debugf("fsutil.IsTarFile(%s): error - %v", target, err)
271 return false
272 }
273
274 return true
275}
276
277func HasReadAccess(dst string) (bool, error) {
278 err := unix.Access(dst, unix.R_OK)

Callers 2

OnCommandFunction · 0.92
BuildMethod · 0.92

Calls 2

CloseMethod · 0.65
NextMethod · 0.45

Tested by

no test coverage detected