I'm trying to perform DFS on a folder that can contain sub folders. The goal is to locate all .txt
files from a directory. I need to find the .txt
files in the order that DFS finds them and preserve the order of files in a folder.
Currently my code for scanning a directory uses the scandir()
function:
int n = scandir(path, &namelist, NULL, alphasort);
This sorts the files in a folder in alphabetical order, which isn't exactly what I want.
Edit: I've tried using opendir() and readdir() but this is accessing files in a seemingly random order.