⬗ (Osu! Background Manager) A little utility to replace, retrieve or remove backgrounds for every beatmap in your osu! folder ⬖
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

45 lines
1.1 KiB

package manager
import (
"errors"
"fmt"
"os"
"path/filepath"
)
// filepath.Joins the main osu directory with its songs folder
func getSongsDir(baseOsuDir string) (string, error) {
songsDir := filepath.Join(baseOsuDir, "Songs")
stat, err := os.Stat(songsDir)
if err != nil {
return "", errors.New(fmt.Sprintf("Could not process the given path : %s", err))
}
if !stat.IsDir() {
return "", errors.New("Given Osu! directory is not a directory !")
}
return songsDir, nil
}
// returns an array of full filepaths to each beatmap from given base Osu! directory
func GetBeatmapFolderPaths(baseOsuDir string) ([]string, error) {
songsDir, err := getSongsDir(baseOsuDir)
if err != nil {
return nil, err
}
contents, err := os.ReadDir(songsDir)
if err != nil {
return nil, errors.New(fmt.Sprintf("Could not read a directory : %s", err))
}
var beatmapFolderPaths []string
for _, file := range contents {
if file.IsDir() {
path := filepath.Join(songsDir, file.Name())
beatmapFolderPaths = append(beatmapFolderPaths, path)
}
}
return beatmapFolderPaths, nil
}