how to get the list of files with a certain extension in a folder ?
Hi All,
Is there any C/C++ API in Linux that I can use to get the names of the files in a folder with a certain extension ? I came across readdir() and scandir() functions. readdir() gives the list of all files - it does not seem to be providing any filtering option. scandir() provides some filtering options, but I could not understand if it is capable of giving me the names of the files with a certain extension. I just want to avoid extra string processing in my application, but have C/C++ API perform that instead. Any ideas ? Thanks. |
The scandir filtering option is merely a function that you provide to the scandir. You can write your own function to test for the extension (but obviously this requires a string comparison).
|
Moved: This thread is more suitable in Programming and has been moved accordingly to help your thread/question get the exposure it deserves.
|
All times are GMT -5. The time now is 02:09 PM. |