mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 20:34:37 +03:00
Moved everything out of internal
This commit is contained in:
35
manager/jsonschema/studio.go
Normal file
35
manager/jsonschema/studio.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package jsonschema
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
type Studio struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Url string `json:"url,omitempty"`
|
||||
Image string `json:"image,omitempty"`
|
||||
}
|
||||
|
||||
func LoadStudioFile(filePath string) (*Studio, error) {
|
||||
var studio Studio
|
||||
file, err := os.Open(filePath)
|
||||
defer file.Close()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
jsonParser := json.NewDecoder(file)
|
||||
err = jsonParser.Decode(&studio)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &studio, nil
|
||||
}
|
||||
|
||||
func SaveStudioFile(filePath string, studio *Studio) error {
|
||||
if studio == nil {
|
||||
return fmt.Errorf("studio must not be nil")
|
||||
}
|
||||
return marshalToFile(filePath, studio)
|
||||
}
|
||||
Reference in New Issue
Block a user