I have read many ways to get list of all files in a directory (e.g. scan a directory to find files in c), but I also want to get their full paths (eg C:\example\file.mp3
).
How is it possible?
I have read many ways to get list of all files in a directory (e.g. scan a directory to find files in c), but I also want to get their full paths (eg C:\example\file.mp3
).
How is it possible?
If you happen to use fts(3)
there's the fts_path
slot that contains the paths to the files relative to what you put in fts_open()
.
So I imagine you'd open your directories like this:
char *dirs[] = {"C:\example", NULL}
fts_open(dirs, 0, NULL);
and then you get full paths in the fts_path
member of the FTSENT
object.
Use dirent.h, it will enable you to populate something like a linked list with the full path of everything in that directory