From 3902b5dd0edcff50b8ddb9990a01b54cb4af6022 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Sat, 8 Mar 2025 11:07:07 +0100 Subject: [PATCH] Have cursor cook some shit up I cbaaaaaaaaaaa.. --- main.go | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index fb2677a..cde8069 100644 --- a/main.go +++ b/main.go @@ -7,6 +7,7 @@ import ( "log" "os" "path/filepath" + "sort" "strings" "sync" "sync/atomic" @@ -78,10 +79,56 @@ func main() { } wg.Wait() + // Create a map to store raw extension names and their binary vs text counts + extensionBinaryTextCount := make(map[string][2]int) + + // Collect all raw extensions and their counts extensionTypeCount.Range(func(key, value any) bool { - log.Printf("Extension: %s, Count: %d", key, value.(int)) + keyStr := key.(string) + count := value.(int) + + // Check if it's a text file (has " (text)" suffix) + if strings.HasSuffix(keyStr, " (text)") { + baseExt := strings.TrimSuffix(keyStr, " (text)") + counts, exists := extensionBinaryTextCount[baseExt] + if !exists { + counts = [2]int{0, 0} + } + counts[1] = count // index 1 for text count + extensionBinaryTextCount[baseExt] = counts + } else { + // Binary file + counts, exists := extensionBinaryTextCount[keyStr] + if !exists { + counts = [2]int{0, 0} + } + counts[0] = count // index 0 for binary count + extensionBinaryTextCount[keyStr] = counts + } return true }) + + // Get all extensions that have more binary occurrences than text + var binaryDominantExts []string + for ext, counts := range extensionBinaryTextCount { + binaryCount := counts[0] + textCount := counts[1] + + if binaryCount > textCount { + binaryDominantExts = append(binaryDominantExts, ext) + } + } + + // Sort the extensions + sort.Strings(binaryDominantExts) + + // Print only the extensions that are more likely to be binary + fmt.Println("Extensions that are predominantly binary:") + for _, ext := range binaryDominantExts { + counts := extensionBinaryTextCount[ext] + fmt.Printf("Extension: %s, Binary Count: %d, Text Count: %d\n", + ext, counts[0], counts[1]) + } } func IsStringBinary(s string) bool {