1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
ErrorStatus OpenFiles( ifstream& masterIn, ifstream& timeClockIn, ofstream& masterOut, ofstream& detailOut )
{
char* filenamePtr;
ErrorStatus error = NONE;
int weekNumber = GetWeekNumber( );
// repeat this for each of the files to be opened
filenamePtr = BuildFilename( "Master", weekNumber, ".txt" );
cout << filenamePtr << endl;//test return
masterIn.open( filenamePtr );
if ( !masterIn ) {
error = error | MASTER_IN;
}//endif
filenamePtr = BuildFilename( "TimeClock", weekNumber, ".txt" );
timeClockIn.open( filenamePtr );
if ( !timeClockIn ) {
error = error | TIMECLOCK_IN;
}//endif
filenamePtr = BuildFilename( "MasterOutput", weekNumber, ".txt" );
masterOut.open( filenamePtr );
if ( !masterOut ) {
error = error | MASTER_OUT;
}//endif
filenamePtr = BuildFilename( "Detail", weekNumber, ".txt" );
detailOut.open( filenamePtr );
if ( !detailOut ) {
error = error | DETAIL_OUT;
}//endif
return error;
}//endfn OpenFiles
char* BuildFilename( char* primary, int weekNumber, char* extention)
{
char fileName[64] = "";
char numberToChar[3];
itoa (weekNumber,numberToChar, 10);
//cout << numberToChar << endl;
strcat(fileName, primary);
//cout << fileName << endl;
strcat(fileName, numberToChar);
//cout << fileName << endl;
strcat(fileName, extention);
cout << fileName << endl;//test
char* returnName = fileName;
return returnName;
}//endfn BuildFilename
|