Sep 30, 2013 at 7:10pm UTC
¿so what does that snip do?
Oct 1, 2013 at 11:03am UTC
Actually the whole program looks like below, and i will like to use it on ubuntu, but ubuntu doesnt recognise the lines above.
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
#include <sys/types.h>
#include <dirent.h>
#include <sys/stat.h>
#include <unistd.h>
using namespace std;
int main()
{
path = opendir( dirpath.c_str() );
string searchPattern = "*.epol";
string fullSearchPath = path + searchPattern;
WIN32_FIND_DATA FindData;
HANDLE hFind;
hFind = FindFirstFile( fullSearchPath.c_str(), &FindData );
if( hFind == INVALID_HANDLE_VALUE )
{
cout << "Error searching directory\n";
return -1;
}
do
{
string filePath = path + FindData.cFileName;
ifstream in( filePath.c_str() );
if( in )
{
// do stuff with the file here
}
else
{
cout << "Problem opening file " << FindData.cFileName << "\n";
}
}
while( FindNextFile(hFind, &FindData) > 0 );
if( GetLastError() != ERROR_NO_MORE_FILES )
{
cout << "Something went wrong during searching\n";
}
system("pause");
return 0;
}
Oct 1, 2013 at 11:16am UTC
I have read that already, thanks alot. But the problem i have now is that i want my program to search for the files with ".epol" ending and open it. I am a "noob" in C++, so please go easy on me ... ;-)
Oct 1, 2013 at 3:40pm UTC
You should do filename checks on your own.
It's not that hard.