MCPcopy
hub / github.com/fogleman/nes / loadThumbnail

Method loadThumbnail

ui/texture.go:110–131  ·  view source on GitHub ↗
(romPath string)

Source from the content-addressed store, hash-verified

108}
109
110func (t *Texture) loadThumbnail(romPath string) image.Image {
111 _, name := path.Split(romPath)
112 name = strings.TrimSuffix(name, ".nes")
113 name = strings.Replace(name, "_", " ", -1)
114 name = strings.Title(name)
115 im := CreateGenericThumbnail(name)
116 hash, err := hashFile(romPath)
117 if err != nil {
118 return im
119 }
120 filename := thumbnailPath(hash)
121 if _, err := os.Stat(filename); os.IsNotExist(err) {
122 go t.downloadThumbnail(romPath, hash)
123 return im
124 } else {
125 thumbnail, err := loadPNG(filename)
126 if err != nil {
127 return im
128 }
129 return thumbnail
130 }
131}
132
133func (t *Texture) downloadThumbnail(romPath, hash string) error {
134 url := thumbnailURL(hash)

Callers 1

loadMethod · 0.95

Calls 5

downloadThumbnailMethod · 0.95
CreateGenericThumbnailFunction · 0.85
hashFileFunction · 0.85
thumbnailPathFunction · 0.85
loadPNGFunction · 0.85

Tested by

no test coverage detected