Start refactor of code into what I think is a more modular way of working

This commit is contained in:
2020-01-26 12:16:37 +00:00
parent eadbe9e743
commit 3e6bcbc5a8
8 changed files with 236 additions and 72 deletions
-40
View File
@@ -50,43 +50,3 @@ func FileSearchUnix() []string {
}
return filesPotential
}
// returns paths with eve chat log files
func PathSearch() []string {
var pathsWithLogs []string
fmt.Println("PathSearch looking for chat log files..")
searchPath = append(searchPath, "~/.local/share/Steam/steamapps/compatdata/8500/pfx/drive_c/users/steamuser/My Documents/EVE/logs/Chatlogs")
userName, _ := user.Current()
homeDir := userName.HomeDir
for _, d := range searchPath {
// if has trailing slash, remove it
d = strings.TrimSuffix(d, "/")
// do a unix like expansion if the path starts like `~/`
if strings.HasPrefix(d, "~/") {
d = filepath.Join(homeDir, d[2:])
}
f, err := os.Open(d)
if err != nil {
log.Fatal(err)
}
files, err := f.Readdir(-1)
if err != nil {
log.Fatal(err)
}
err = f.Close()
if err != nil {
log.Fatal(err)
}
if len(files) > 0 {
pathsWithLogs = append(pathsWithLogs, d)
}
fmt.Println(len(files))
}
return pathsWithLogs
}