-
Notifications
You must be signed in to change notification settings - Fork 0
/
application.go
45 lines (38 loc) · 938 Bytes
/
application.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package application
import (
"fmt"
"os"
"./filesystem"
)
type Application struct {
Name string
Version Version
Process *Process
IO *IO
Data filesystem.Directory
Config filesystem.Directory
}
func Initialize(name string, version Version) *Application {
app := &Application{
Name: name,
Version: version,
IO: &IO{
Output: os.Stdout(),
Input: os.Stdin(),
Error: os.Stderr(),
},
Data: filesystem.Directory{
Path: filesystem.Path{fmt.Sprintf("/home/%s/%s/%s", os.Getenv("USER"), ".local/share", name)},
},
Config: filesystem.Directory{
Path: filesystem.Path{fmt.Sprintf("/home/%s/%s/%s", os.Getenv("USER"), ".config", name)},
},
}
if _, err := os.Stat(app.Data.Path); os.IsNotExist(err) {
_ = os.MkdirAll(app.Data.Path, os.FileMode(0770))
}
if _, err := os.Stat(app.Config.Path); os.IsNotExist(err) {
_ = os.MkdirAll(app.Config.Path, os.FileMode(0770))
}
return app
}