Dirent.h - get the strings for files with a certain extension exclusively
<p>Having a few issues trying to think of a good way to have a directory traverser that will only select wav files and return the strings for those files exclusively, e.g. just wav files. I can stop dirent.h looking in subdirectories, I'm pretty sure I just need an if statement that only allows files with .wav in string</p>

<p>So far my code looks like this, I just extended a few examples I've seen on the wiki page for the header file:</p>

<pre><code>ifstream fin;
string dir, filepath;
DIR *dp;
struct dirent *dirp;
struct stat filestat;


cout &lt;&lt; "dir to get files of: " &lt;&lt; flush;

getline(cin, dir);

dp = opendir( dir.c_str() );

if (dp == NULL){

    cout &lt;&lt; "Error(" &lt;&lt; errno &lt;&lt; ") opening " &lt;&lt; dir &lt;&lt; endl;

    }

while ((dirp = readdir( dp ))){

    filepath = dir + "/" + dirp-&gt;d_name;

    if (stat( filepath.c_str(), &amp;filestat )) continue;
    if (S_ISDIR( filestat.st_mode ))         continue;

    fin.open( filepath.c_str() );

    stringVec.push_back(filepath);

    fin.close();

    }

closedir( dp );

for(int i=0;i&lt;stringVec.size();i++){
    cout &lt;&lt; stringVec[i] &lt;&lt; endl;

}
</code></pre>

<p>Any help appreciated, I'm its not super difficult - but so far I haven't been able to figure it out.</p>
