0

After some research on google and stackoverflow I came to the conclusion to ask this question myself:

Is there a more or less portable way to get a list of all files from a directory?

I want to support a shortcut in my application where you can give it a directory from the command line and it traverses it and its subdirectories automatically. I am free to use C and C++ but don't want to depand on any thrid-party libraries if possible.

Thanks in advance!

Edit:

Regarding the duplicate-question: I already found that one and tried it but the dirent.h wasn't working for me. That's why I wrote this. Also regarding C/C++: my application is currently written in pure C and I would favor a C-only solution but if a better C++ solution is suggested it would also be acceptable.

too honest for this site
  • 12,050
  • 4
  • 30
  • 52
  • Nominating this question for reopening, as the provided "duplicate" question has answers that are now nearly 8 years old, and the C++ language has advanced since then, changing the correct answer. – Xirema Jan 16 '17 at 17:11
  • As `C` and `C++` are different languages, the OP should choose one. Until that time it's safe to assume this will remain closed. Note that the `dirent` answer from 8 years ago is a good answer today in `C`. – KevinDTimm Jan 16 '17 at 17:16
  • @Xirema: OP asks for a C solution in the first place (that or the question is too broad asking for two different languages). And that has not changed in the last 18 years. – too honest for this site Jan 16 '17 at 17:40
  • What OS are you using? The answer is OS dependent. – dbush Jan 16 '17 at 17:41

0 Answers0