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

Function IsBinaryFile

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

Source from the content-addressed store, hash-verified

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

Callers 1

processFilesFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected