diff --git a/ls/ls.go b/ls/ls.go index c221bad..950ebf9 100644 --- a/ls/ls.go +++ b/ls/ls.go @@ -44,33 +44,31 @@ func Stat(p string) (os.FileInfo, error) { } func ls(p string, fold int) error { - if fold == 0 { - return nil - } isDir, e := IsDir(p) if e != nil { return e } pp := strings.TrimRight(p, "/") - if isDir && !dirFlag { - l, e := ReadDir(p) - if e != nil { + if !isDir || dirFlag || fold<1 { + fmt.Println(pp); + }else{ + l, e := ReadDir(pp) + if e!=nil { return e } for _, f := range l { s := pp+"/"+f.Name() - fmt.Println(s) - ls(s, fold-1) + if b, _:=IsDir(s) ; b { + fmt.Println(s) + } + if 0