fixed some path issues

This commit is contained in:
ston1th 2019-05-02 14:50:28 +02:00
commit 38c2a72fe0
5 changed files with 22 additions and 28 deletions

View file

@ -69,7 +69,6 @@ func (fs *Filesystem) ReadDir(path string) (d *Directory) {
func (fs *Filesystem) Recursive(p string) (paths core.Paths) {
p = Clean(p)
p, _ = filepath.Split(p)
if len(p) >= 2 {
p = p[:len(p)-1]
}
@ -91,14 +90,12 @@ func (fs *Filesystem) Recursive(p string) (paths core.Paths) {
}
func (fs *Filesystem) RecursiveFiles(p string) (files []string) {
p = Clean(p)
fullpath := filepath.Join(fs.Base, p)
filepath.Walk(fullpath, func(path string, info os.FileInfo, err error) error {
filepath.Walk(filepath.Join(fs.Base, Clean(p)), func(path string, info os.FileInfo, err error) error {
if err != nil {
return nil
}
if info.Mode().IsRegular() {
files = append(files, strings.TrimPrefix(path, fullpath))
files = append(files, strings.TrimPrefix(path, fs.Base))
}
return nil
})
@ -106,8 +103,7 @@ func (fs *Filesystem) RecursiveFiles(p string) (files []string) {
}
func Paths(path string) (p core.Paths) {
path = Clean(path)
s := strings.Split(path, string(filepath.Separator))
s := strings.Split(Clean(path), string(filepath.Separator))
for i, v := range s[1:] {
if v == "" {
continue