package shortcut import ( "errors" "strings" "imuslab.com/arozos/mod/filesystem/arozfs" ) /* A simple package to better handle shortcuts in ArozOS Author: tobychui */ func ReadShortcut(shortcutContent []byte) (*arozfs.ShortcutData, error) { //Split the content of the shortcut files into lines fileContent := strings.ReplaceAll(strings.TrimSpace(string(shortcutContent)), "\r\n", "\n") lines := strings.Split(fileContent, "\n") if len(lines) < 4 { return nil, errors.New("Corrupted Shortcut File") } for i := 0; i < len(lines); i++ { lines[i] = strings.TrimSpace(lines[i]) } //Render it as shortcut data result := arozfs.ShortcutData{ Type: lines[0], Name: lines[1], Path: lines[2], Icon: lines[3], } return &result, nil }