mirror of
https://github.com/jimeh/build-emacs-for-macos.git
synced 2026-02-19 06:06:40 +00:00
48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
package assets
|
|
|
|
import (
|
|
_ "embed"
|
|
"os"
|
|
)
|
|
|
|
//go:generate tiffutil -cathidpicheck bg.png bg@2x.png -out bg.tif
|
|
|
|
// Background is a raw byte slice of bytes of bg.tiff
|
|
//
|
|
//go:embed bg.tif
|
|
var Background []byte
|
|
|
|
// BackgroundTempFile writes Background to a temporary file on disk, returning
|
|
// the resulting file path. The returned filepath should be deleted with
|
|
// os.Remove() when no longer needed.
|
|
func BackgroundTempFile() (string, error) {
|
|
return tempFile("*-emacs-bg.tif", Background)
|
|
}
|
|
|
|
// Icon is a raw byte slice of bytes of vol.icns
|
|
//
|
|
//go:embed vol.icns
|
|
var Icon []byte
|
|
|
|
// IconTempFile writes Icon to a temporary file on disk, returning the resulting
|
|
// file path. The returned filepath should be deleted with os.Remove() when no
|
|
// longer needed.
|
|
func IconTempFile() (string, error) {
|
|
return tempFile("*-emacs-vol.icns", Icon)
|
|
}
|
|
|
|
func tempFile(pattern string, content []byte) (string, error) {
|
|
f, err := os.CreateTemp("", pattern)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
defer f.Close()
|
|
|
|
_, err = f.Write(content)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
return f.Name(), nil
|
|
}
|