MCPcopy Create free account
hub / github.com/cli/cli / IsBinaryFile

Function IsBinaryFile

pkg/cmd/gist/shared/shared.go:198–212  ·  view source on GitHub ↗
(file string)

Source from the content-addressed store, hash-verified

196}
197
198func IsBinaryFile(file string) (bool, error) {
199 detectedMime, err := mimetype.DetectFile(file)
200 if err != nil {
201 return false, err
202 }
203
204 isBinary := true
205 for mime := detectedMime; mime != nil; mime = mime.Parent() {
206 if mime.Is("text/plain") {
207 isBinary = false
208 break
209 }
210 }
211 return isBinary, nil
212}
213
214func IsBinaryContents(contents []byte) bool {
215 isBinary := true

Callers 1

processFilesFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected