Skip to content

Commit

Permalink
add limit -1 for unlimited result
Browse files Browse the repository at this point in the history
  • Loading branch information
andypangaribuan committed Dec 15, 2020
1 parent 77ab46a commit 4249560
Showing 1 changed file with 4 additions and 46 deletions.
50 changes: 4 additions & 46 deletions v-utils/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (slf *filesStruct) GetFilesRecursively(dirPath string, extensions []string,

dirs := make([]string, 0)
for _, file := range fi {
if len(files) >= limit {
if len(files) >= limit && limit != -1 {
break
}

Expand Down Expand Up @@ -86,65 +86,23 @@ func (slf *filesStruct) GetFilesRecursively(dirPath string, extensions []string,
}
}

if len(files) < limit {
if len(files) < limit || limit == -1 {
for _, dir := range dirs {
_err := readDir(dir)
if _err != nil {
err = _err
break
}

if len(files) >= limit {
if len(files) >= limit && limit != -1 {
break
}
}
}

return
}



err = readDir(dirPath)






//fi, _err := ioutil.ReadDir(dirPath)
//if _err != nil {
// err = errors.WithStack(_err)
// return
//}
//
//for _, file := range fi {
// if len(files) >= limit {
// break
// }
//
// if !file.IsDir() && file.Size() > 0 {
// add := extension == ""
// fileName := file.Name()
// fullPath := dirPath + string(os.PathSeparator) + fileName
//
// if extension != "" {
// if extension == slf.GetFileExtension(fileName) {
// add = true
// }
// }
//
// if add && condition != nil {
// add = condition(fileName, fullPath)
// }
// if add {
// files = append(files, fullPath)
// }
// }
//
// if file.IsDir() {
//
// }
//}

return
}

0 comments on commit 4249560

Please sign in to comment.