Task

Walk a given directory tree and print files matching a given pattern.


Note: This task is for recursive methods.   These tasks should read an entire directory tree, not a single directory.


Note: Please be careful when running any code examples found here.



Related task

   Walk a directory/Non-recursively   (read a single directory). 


$ include "seed7_05.s7i";
  include "osfiles.s7i";
 
const proc: walkDir (in string: dirName, in string: extension) is func
  local
    var string: fileName is "";
    var string: path is "";
  begin
    for fileName range readDir(dirName) do
      path := dirName & "/" & fileName;
      if endsWith(path, extension) then
        writeln(path);
      end if;
      if fileType(path) = FILE_DIR then
        walkDir(path, extension);
      end if;
    end for;
  end func;
 
const proc: main is func
  begin
    walkDir(".", ".sd7");
  end func;