-1

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?

Community
  • 1
  • 1

2 Answers2

0

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.

hroptatyr
  • 4,702
  • 1
  • 35
  • 38
0

Use dirent.h, it will enable you to populate something like a linked list with the full path of everything in that directory