WIN32_FIND_DATA

I have compiled a program on windows and will like to do the equivalent on Ubuntu. I need help please.

1
2
3
4
  WIN32_FIND_DATA FindData;
    HANDLE hFind;
 
    hFind = FindFirstFile( fullSearchPath.c_str(), &FindData );
¿so what does that snip do?
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;
}
kbw wrote:
See opendir/readdir ...

There's an example here.
http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=%2Fapis%2Fopendir.htm
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 ... ;-)
You should do filename checks on your own.
It's not that hard.
Topic archived. No new replies allowed.