let filesInPath = toSeq(walkDir("path", relative=true))
The easiest way I can think of would be to do the following.
import os, sugar
let files = collect(newSeq):
for file in walkFiles("*"):
file
imho the most idiomatic way of doing this is:
import os
var paths: seq[string] = @[]
for path in walkFiles("*"):
paths.add path
If we're going to do it without sugar atleast make it the same result with an immutable list of files.
import os
let files = block:
var res: seq[string]
for f in walkFiles("*"): res.add(f)
if only the file name is required:
proc all_files*(path:string):seq[string] = toSeq(walkDir(path)).mapIt(it.path)