From 12bb16228ebd5b5bdbc3d30a8cf92670fbe5ab85 Mon Sep 17 00:00:00 2001 From: jienfak Date: Thu, 23 Apr 2020 12:41:19 +0500 Subject: [PATCH] ls: now it works properly. --- ls/ls.go | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) 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