Finish implementation of clipboard writing

This commit is contained in:
Kovid Goyal
2022-12-03 08:02:27 +05:30
parent 71e09ba1fb
commit bde737fa38
4 changed files with 220 additions and 45 deletions

24
tools/utils/mimetypes.go Normal file
View File

@@ -0,0 +1,24 @@
// License: GPLv3 Copyright: 2022, Kovid Goyal, <kovid at kovidgoyal.net>
package utils
import (
"fmt"
"mime"
"path/filepath"
)
var _ = fmt.Print
func GuessMimeType(filename string) string {
ext := filepath.Ext(filename)
mime_with_parameters := mime.TypeByExtension(ext)
if mime_with_parameters == "" {
return mime_with_parameters
}
ans, _, err := mime.ParseMediaType(mime_with_parameters)
if err != nil {
return ""
}
return ans
}