mirror of
https://github.com/elyby/chrly.git
synced 2024-12-23 21:50:03 +05:30
31 lines
518 B
Go
31 lines
518 B
Go
package files
|
|
|
|
import (
|
|
"os"
|
|
"path"
|
|
"strings"
|
|
|
|
"elyby/minecraft-skinsystem/model"
|
|
)
|
|
|
|
type filesDb struct {
|
|
path string
|
|
}
|
|
|
|
func (repository *filesDb) FindByUsername(username string) (model.Cape, error) {
|
|
var record model.Cape
|
|
if username == "" {
|
|
return record, CapeNotFoundError{username}
|
|
}
|
|
|
|
capePath := path.Join(repository.path, strings.ToLower(username) + ".png")
|
|
file, err := os.Open(capePath)
|
|
if err != nil {
|
|
return record, CapeNotFoundError{username}
|
|
}
|
|
|
|
record.File = file
|
|
|
|
return record, nil
|
|
}
|