-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpaths.go
More file actions
74 lines (68 loc) · 1.96 KB
/
Copy pathpaths.go
File metadata and controls
74 lines (68 loc) · 1.96 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package main
import (
"fmt"
"os"
"path/filepath"
"runtime"
)
func findLogFile() (string, error) {
home, err := os.UserHomeDir()
if err != nil {
return "", fmt.Errorf("could not get user home directory: %v", err)
}
potentialPaths := getLogFilePaths(home)
for _, p := range potentialPaths {
if _, err := os.Stat(p); err == nil {
return p, nil
}
}
return "", fmt.Errorf("could not find console.log in common locations for %s", runtime.GOOS)
}
func getLogFilePaths(home string) []string {
switch runtime.GOOS {
case "windows":
return []string{
`C:\Program Files (x86)\Steam\steamapps\common\Counter-Strike Global Offensive\game\csgo\console.log`,
`D:\SteamLibrary\steamapps\common\Counter-Strike Global Offensive\game\csgo\console.log`,
}
case "linux":
return []string{
filepath.Join(home, ".steam/steam/steamapps/common/Counter-Strike Global Offensive/game/csgo/console.log"),
filepath.Join(home, ".local/share/Steam/steamapps/common/Counter-Strike Global Offensive/game/csgo/console.log"),
}
case "darwin":
return []string{
filepath.Join(home, "Library/Application Support/Steam/steamapps/common/Counter-Strike Global Offensive/game/csgo/console.log"),
}
}
return nil
}
func getUserdataPaths(home string) []string {
switch runtime.GOOS {
case "windows":
return []string{`C:\Program Files (x86)\Steam\userdata`}
case "linux":
return []string{
filepath.Join(home, ".steam/steam/userdata"),
filepath.Join(home, ".local/share/Steam/userdata"),
}
case "darwin":
return []string{filepath.Join(home, "Library/Application Support/Steam/userdata")}
}
return nil
}
func getConfigFilePaths(dataPaths []string) []string {
var configs []string
for _, dataPath := range dataPaths {
entries, err := os.ReadDir(dataPath)
if err != nil {
continue
}
for _, entry := range entries {
if entry.IsDir() {
configs = append(configs, filepath.Join(dataPath, entry.Name(), "config", "localconfig.vdf"))
}
}
}
return configs
}