I have put the bare bones essential parts of my code in this post to see if anyone could offer advice. Currently its uses the ifstream 'infile' to run and only handles 1 file. If i could use the ifstream 'filepath', that contains a path for every file in a folder, my problems would be solved!
thanks in advance for any advice offered
Code:
DIR *d;
struct dirent *dir;
//THIS IS MY STRUCTURE IN MAIN THAT RUNS THROUGH ALL FILES IN A DIRECTORY. ITS PROBABLY MESSY BUT IT WORKS
cout << "Enter the name OF FOLDER: ";
string g_1;
getline( cin, g_1 );
d = opendir ( g_1.c_str() );
if ( d )
{
while ( ( dir = readdir ( d ) ) != NULL )
{
string filepath;
string g = dir->d_name;
string filename1 = g_1 + g; //concat the paths
filepath = filename1;
ifstream infile11( filepath.c_str(), ios::binary );
read.close();
}
closedir ( d );
}
getchar();
return ( 0 );
// CURRENTLY I USE THIS IFSTREAM TO MAKE MY PROGRAM WORK FOR JUST ONE FILE I HAVE CUT OUT THE USER INPUT AS IT ISNT REALLY APPLICABLE
ifstream infile( filename.c_str(), ios::binary );
//THIS LOOP PICKS UP THE IF STREAM AND IS THE START OF ALL OF MY PROCESSES. IF I CAN SOMEHOW PASS THE IFSTREAM ''FILEPATH'' TO THIS LOOP FOR EVERY FILE THAT IS FOUND IN A FOLDER THIS WOULD SOLVE ALL MY PROBLEMS
while(lastPositionFound>=0)
{
int dataStart;
int dataEnd;
// Find start of data chunk
lastPositionFound = find(infile, match_criteria, 2, lastPositionFound);
dataStart=lastPositionFound;
if(lastPositionFound>=0)
{
lastPositionFound = find(infile, match_criteria1, 1, lastPositionFound);
dataEnd = lastPositionFound+1;
}
if(lastPositionFound>=0)
{
// Handle file
ExportChunk(infile,outputfilename, dataStart, dataEnd);
//outputfilename[12]++;
}
}
infile.close();