MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / IsBinaryContent

Function IsBinaryContent

pkg/util/utilfn/utilfn.go:1104–1126  ·  view source on GitHub ↗
(data []byte)

Source from the content-addressed store, hash-verified

1102
1103
1104func IsBinaryContent(data []byte) bool {
1105 if len(data) == 0 {
1106 return false
1107 }
1108 sampleSize := min(8192, len(data))
1109 sample := data[:sampleSize]
1110
1111 nullCount := 0
1112 for _, b := range sample {
1113 if b == 0 {
1114 nullCount++
1115 }
1116 }
1117 if float64(nullCount)/float64(len(sample)) > 0.01 {
1118 return true
1119 }
1120
1121 if !utf8.Valid(sample) {
1122 return true
1123 }
1124
1125 return false
1126}
1127
1128func FormatRelativeTime(modTime time.Time) string {
1129 now := time.Now()

Callers 1

readTextFileCallbackFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected