I wonder if it is possible with function pointers or macros or the like, to make the code below more modular, as in, not repeat the whole for loop, with the only difference being the walkDirRec vs walkDir.
I tried with function pointers and a macro, but did not manage to get either one working. (-> nim-noob)
import os
proc containsFilesWithSuffix(dir: string, suffix: string, recursive: bool = true) : bool =
if recursive:
for file in os.walkDirRec(dir):
if file.toLower().endsWith(suffix):
return true
else:
for file in os.walkDir(dir):
if file.toLower().endsWith(suffix):
return true
return false