-
Notifications
You must be signed in to change notification settings - Fork 1
/
appdir_windows.go
37 lines (28 loc) · 945 Bytes
/
appdir_windows.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
// +build windows
package appdir
import (
"errors"
"os"
"path/filepath"
)
// DataRoot returns the path to the root folder for an app's data
func (info AppInfo) DataRoot() (string, error) {
var appDataDir string
if appDataDir = os.Getenv("APPDATA"); appDataDir == "" {
return "", errors.New("%APPDATA% not set")
}
return filepath.Join(appDataDir, "Roaming", info.Author, info.Name), nil
}
// ConfigRoot returns the path to the root folder for an app's config
func (info AppInfo) ConfigRoot() (string, error) {
// In Windows, there are no separate config and data directories
return info.DataRoot()
}
// CacheRoot returns the path to the root folder for an app's cache data
func (info AppInfo) CacheRoot() (string, error) {
var appDataDir string
if appDataDir = os.Getenv("APPDATA"); appDataDir == "" {
return "", errors.New("%APPDATA% not set")
}
return filepath.Join(appDataDir, "Local", info.Author, info.Name), nil
}