binmeta

package
v1.6.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2024 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrIconIgnored = errors.New("icon is ignored")

ErrIconIgnored is returned when the icon should be ignored.

View Source
var ProfileIconStoragePath = ""

ProfileIconStoragePath defines the location where profile icons are stored. Must be set before anything else from this package is called. Must not be changed once set.

Functions

func ConvertICOtoPNG

func ConvertICOtoPNG(ico []byte) (png []byte, err error)

ConvertICOtoPNG converts a an .ico to a .png image.

func GenerateBinaryNameFromPath

func GenerateBinaryNameFromPath(path string) string

GenerateBinaryNameFromPath generates a more human readable binary name from the given path. This function is used as fallback in the GetBinaryName functions.

func GetProfileIcon

func GetProfileIcon(name string) (data []byte, err error)

GetProfileIcon returns the profile icon with the given ID and extension.

func IgnoreIcon added in v1.6.8

func IgnoreIcon(name string) bool

IgnoreIcon returns whether an icon should be ignored or not.

func UpdateProfileIcon

func UpdateProfileIcon(data []byte, ext string) (filename string, err error)

UpdateProfileIcon creates or updates the given icon.

Types

type Icon

type Icon struct {
	Type   IconType
	Value  string
	Source IconSource
}

Icon describes an icon.

func GetIconAndName

func GetIconAndName(ctx context.Context, binPath string, homeDir string) (icon *Icon, name string, err error)

GetIconAndName returns an icon and name of the given binary path. Providing the home directory of the user running the process of that binary can improve results. Even if an error is returned, the other return values are valid, if set.

func LoadAndSaveIcon

func LoadAndSaveIcon(ctx context.Context, iconPath string) (*Icon, error)

LoadAndSaveIcon loads an icon from disk, updates it in the icon database and returns the icon object.

func SortAndCompactIcons

func SortAndCompactIcons(icons []Icon) []Icon

SortAndCompactIcons sorts and compacts a list of icons.

func (Icon) GetIconAsDataURL

func (icon Icon) GetIconAsDataURL() (bloburl string, err error)

GetIconAsDataURL returns the icon data as a data URL.

type IconInDatabase

type IconInDatabase struct {
	sync.Mutex
	record.Base

	IconData string `json:"iconData,omitempty"` // DataURL
}

IconInDatabase represents an icon saved to the database.

func EnsureIconInDatabase

func EnsureIconInDatabase(r record.Record) (*IconInDatabase, error)

EnsureIconInDatabase ensures that the given record is a *IconInDatabase, and returns it.

type IconLocation

type IconLocation struct {
	Directory string
	Type      IconLocationType
	PathArg   PathArg
}

IconLocation describes an icon location.

func (IconLocation) GetPath

func (il IconLocation) GetPath(binName string, homeDir string) string

GetPath returns the path of an icon.

type IconLocationType

type IconLocationType uint8

IconLocationType describes an icon location type.

const (
	FlatDir IconLocationType = iota
	XDGIcons
)

Icon Location Types.

type IconSource

type IconSource string

IconSource describes the source of an Icon.

const (
	IconSourceUser   IconSource = "user"
	IconSourceImport IconSource = "import"
	IconSourceUI     IconSource = "ui"
	IconSourceCore   IconSource = "core"
)

Supported icon sources.

type IconType

type IconType string

IconType describes the type of an Icon.

const (
	IconTypeFile     IconType = "path"
	IconTypeDatabase IconType = "database"
	IconTypeAPI      IconType = "api"
)

Supported icon types.

type PathArg

type PathArg uint8

PathArg describes an icon location path argument.

const (
	NoPathArg PathArg = iota
	Home
	BinName
)

Path Args.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL