You first pass a directory name to be searched recursively. Now for all subdirectories, you skip .
and ..
and pass remaining directory name recursively to this function.
You never add \*
to this directory name to make it a patter
to seach recursively, which makes FindFirstFile to return this directory itself. (As the directory is the only one that mathes without pattern.) and hence the infinite recursion and stack overflow.
Solution You should append \*
to to the directory name before calling you getAllFiles
function recursively.