⬗ (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.
|
|
|
package util
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
func IsDir(path string) bool {
|
|
|
|
info, err := os.Stat(path)
|
|
|
|
if err != nil {
|
|
|
|
// path error
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if !info.IsDir() {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
// checks if given string contains ".osu" file extention
|
|
|
|
func IsBeatmap(filename string) bool {
|
|
|
|
if len(filename) < 5 {
|
|
|
|
// too short filename to be a beatmap file
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if filename[len(filename)-4:] == ".osu" {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
// checks if given string contains the image file extention
|
|
|
|
func IsImage(filename string) bool {
|
|
|
|
if IsDir(filename) {
|
|
|
|
// given filename is actually a directory
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
var imageExtentions []string = []string{"jpeg", "jpg", "png", "JPEG", "JPG", "PNG"}
|
|
|
|
for _, extention := range imageExtentions {
|
|
|
|
if strings.Contains(filename, extention) {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func DoesExist(path string) bool {
|
|
|
|
_, err := os.Stat(path)
|
|
|
|
if err != nil {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|