cleanup
This commit is contained in:
@@ -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())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
11
|
|
||||||
22
|
|
||||||
Reference in New Issue
Block a user