I'm trying to design an algorithm that I could use in various programs under linux using readdir(), opendir(), etc. and create linked-lists of all the files in directories and sub-directories and am kind of frustrated with HOW to do it. For instance, I can use a readdir() to read all the files in one directory and build a linked-list of all of its files and this could be also a function on its own. Where I seem to get confused is when it comes to processing sub-directories. Should I process an entire directory and build a linked-list of all of its files and then scan that linked-list for sub-directories to open and build linked-lists of those sub-directories, or should I process those sub-directories as I'm building the linked-list of a particular directory using recursion? i.e. As I'm building a directory's linked-list of files and come across a sub-directory open it and build a linked-list of its files, etc. Any ideas?