This commit is contained in:
2019-12-09 22:23:59 +00:00
parent b9ffdfce3c
commit b41d34de39
3 changed files with 0 additions and 53 deletions
-51
View File
@@ -1,51 +0,0 @@
package main
import (
"fmt"
"log"
"os"
"os/user"
"path/filepath"
"strings"
)
func TrimSuffix(s, suffix string) string {
if strings.HasSuffix(s, suffix) {
s = s[:len(s)-len(suffix)]
}
return s
}
func main() {
var searchPath []string
searchPath = append(searchPath,
"/home/starkers/.local/share/Steam/steamapps/compatdata/8500/pfx/drive_c/users/steamuser/My Documents/EVE/logs/Chatlogs")
usr, _ := user.Current()
dir := usr.HomeDir
for _, d := range searchPath {
// if has trailing slash, remove it
d = TrimSuffix(d, "/")
// do a unix like expansion if the path starts like `~/`
if strings.HasPrefix(d, "~/") {
d = filepath.Join(dir, d[2:])
}
f, err := os.Open(d)
if err != nil {
log.Fatal(err)
}
files, err := f.Readdir(-1)
f.Close()
if err != nil {
log.Fatal(err)
}
for _, file := range files {
fmt.Printf("%v/%v\n", d, file.Name())
}
}
}
-2
View File
@@ -1,2 +0,0 @@
11
22
View File