GetSoundFiles returns a sorted list of all sound filenames found recursively under PublicHtml/static/audio/sound/. Files whose names begin with "_" are skipped.
()
| 70 | // GetSoundFiles returns a sorted list of all sound filenames found recursively |
| 71 | // under PublicHtml/static/audio/sound/. Files whose names begin with "_" are skipped. |
| 72 | func GetSoundFiles() []string { |
| 73 | publicHtml := configs.GetFilePathsConfig().PublicHtml.String() |
| 74 | root := filepath.Join(publicHtml, "static", "audio", "sound") |
| 75 | |
| 76 | var files []string |
| 77 | _ = filepath.WalkDir(root, func(path string, d os.DirEntry, err error) error { |
| 78 | if err != nil || d.IsDir() { |
| 79 | return nil |
| 80 | } |
| 81 | name := d.Name() |
| 82 | if strings.HasPrefix(name, "_") { |
| 83 | return nil |
| 84 | } |
| 85 | rel, relErr := filepath.Rel(publicHtml, path) |
| 86 | if relErr != nil { |
| 87 | return nil |
| 88 | } |
| 89 | files = append(files, filepath.ToSlash(rel)) |
| 90 | return nil |
| 91 | }) |
| 92 | sort.Strings(files) |
| 93 | return files |
| 94 | } |
| 95 | |
| 96 | func SaveAudio(entries map[string]AudioConfig) error { |
| 97 | if entries == nil { |
no test coverage detected