github.com/aloncn/graphics-go@v0.0.1/src/mime/type_windows.go (about) 1 // Copyright 2010 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package mime 6 7 import ( 8 "internal/syscall/windows/registry" 9 ) 10 11 func init() { 12 osInitMime = initMimeWindows 13 } 14 15 func initMimeWindows() { 16 names, err := registry.CLASSES_ROOT.ReadSubKeyNames(-1) 17 if err != nil { 18 return 19 } 20 for _, name := range names { 21 if len(name) < 2 || name[0] != '.' { // looking for extensions only 22 continue 23 } 24 k, err := registry.OpenKey(registry.CLASSES_ROOT, name, registry.READ) 25 if err != nil { 26 continue 27 } 28 v, _, err := k.GetStringValue("Content Type") 29 k.Close() 30 if err != nil { 31 continue 32 } 33 setExtensionType(name, v) 34 } 35 } 36 37 func initMimeForTests() map[string]string { 38 return map[string]string{ 39 ".PnG": "image/png", 40 } 41 }