crokett
09-12-2001, 12:03 PM
as written this method traps when it is done running - the destructor traps when it tries to clean up. the code in bold is the offending code, but when I move it to the bottom of the method the program runs with no problem. i am wondering if it is the compiler that is the problem since it shouldn't matter where in the program the code is. i tried flushing the stream but got the same problem. i don't want to simply get it working, i want to figure out what is wrong. i also thought about using a single stream since i am closing each one anyway, but again i don't want to cover up the problem i want to know why. incase it is the compiler, right now i am using VisualC++, though I am also porting it to *nix. thanks for any assistance and you guys always give me better and faster help than the MS forums.
//routine that sets up create drive image scripts
void createImage(char imgDrv, char ftpServer[], char user[], char passwd[], string remotePath,
string remoteFile, string localFile){
char pqdiResponse[200];
pqdiResponse[0]=imgDrv;
pqdiResponse[1]='\0';
strcat(pqdiResponse, ":\\create.txt");
ofstream createtxt;
createtxt.open(pqdiResponse,ios: :out);
createtxt << "SELECT DRIVE 1" << endl;
createtxt << "SELECT PARTITION 2" << endl;
createtxt << "STORE WITH COMPRESSION HIGH" << endl;
createtxt.close();
printf("created PQDI file!\n");
char dgFile[12];
dgFile[0]=imgDrv;
dgFile[1]='\0';
strcat(dgFile,":\\dosgo.bat");
// create dosgo filestream
ofstream dosgo;
// open for ouput on dosgo.bat
dosgo.open(dgFile,ios: :out);
printf("Create image ran!\n");
dosgo << "c:\\pqdi.exe /cmd=%IMGDRV%:\\create.txt /img=%IMGDRV%:\\"
<< imgFile << " /I24 /IFC /NBS /NRB /ERR=%IMGDRV%:\\create.err /LOG=%IMGDRV%:\\create.log" << endl;
dosgo << "if exist %IMGDRV%:\\create.err goto IMGERR" << endl;
dosgo << "call %IMGDRV%:\\errorlog.bat 000 \"Created Image, restarting to Windows\" %IMGDRV%"<< endl;
dosgo << "goto DONE" << endl;
dosgo << ":IMGERR" << endl;
dosgo << "call %IMGDRV%:\\errorlog.bat 851 \"Error creating image file\" %IMGDRV%" << endl;
dosgo << " :DONE" << endl;
dosgo << "call c:\\setpdos.bat" << endl;
dosgo << "call c:\\setactiv.bat" << endl;
// dosgo.flush(); - you have to flush if you don't endl
dosgo.close();
printf("created dosgo file\n");
// the ftpput filestream to put image file
char ftpFile[13];
ftpFile[0]=imgDrv;
ftpFile[1]='\0';
strcat(ftpFile, ":\\ftpput.bat");
ofstream ftpput;
ftpput.open(ftpFile,ios: :out);
ftpput << "if exist " << imgDrv << ":\\ftpdoflg.flg goto :NOFTP" << endl;
ftpput << "c:\\ibm\\iaaconfig\\getfile " << ftpServer << " "
<< user << " " << passwd << " " << remotePath << " " << imgDrv
<< " " << remoteFile << " " << localFile << endl;
ftpput << "if errorlevel 1 goto FTPFAIL" << endl;
ftpput << "call " << imgDrv << ":\\errorlog.bat 000 \"Created file on FTP Server\""
<< imgDrv << endl;
ftpput << "call " << imgDrv << ":\\errorlog.bat 111 \"Create Image Complete\""
<< imgDrv << endl;
ftpput << "goto EXIT" << endl;
ftpput << ":FTPFAIL" << endl;
ftpput << "call " << imgDrv << ":\\errorlog.bat 805 \"Error creating file on FTP Server\" "
<< imgDrv << endl;
ftpput << "goto EXIT" << endl;
ftpput << ":NOFTP" << endl;
ftpput << "call " << imgDrv << ":\\errorlog.bat 000 \"Image created on this machine so not FTPing file up\" "
<< imgDrv << endl;
ftpput << ":EXIT" << endl;
ftpput << "call c:\\ibm\\iaaconfig\\clean.bat c:\\ibm\\iaaconfig "
<< imgDrv << endl;
ftpput.close();
printf("created dftp file\n");
// the autoexnt filestream for autoexnt.bat
string exntBuf = systemDir + "\\autoexnt.bat";
char* autoEXNTBat = new char[exntBuf.length()+1];
exntBuf.copy(autoEXNTBat, exntBuf.length());
*(autoEXNTBat + exntBuf.length()) = 0;
// create autoexnt.bat file
ofstream autoexntfile;
autoexntfile.open(autoEXNTBat,ios: :out);
autoexntfile << "if exist " << rlFlagStr << " call " << installDir
<< "\\restlogic.bat" << endl;
autoexntfile << "if exist " << ftpflag << " call " << installDir
<< "\\ftpput.bat" << endl;
autoexntfile.close();
printf("created autont file\n");
// now create flag files to enable restlogic operation
char* dorlFlg = new char[rlFlagStr.length()+1];
rlFlagStr.copy(dorlFlg, rlFlagStr.length());
*(dorlFlg + rlFlagStr.length()) = 0;
ofstream dorlFile;
dorlFile.open(dorlFlg,ios: :out);
dorlFile << "running restlogic" << endl;
dorlFile.close();
printf("created flag file\n");
}
//routine that sets up create drive image scripts
void createImage(char imgDrv, char ftpServer[], char user[], char passwd[], string remotePath,
string remoteFile, string localFile){
char pqdiResponse[200];
pqdiResponse[0]=imgDrv;
pqdiResponse[1]='\0';
strcat(pqdiResponse, ":\\create.txt");
ofstream createtxt;
createtxt.open(pqdiResponse,ios: :out);
createtxt << "SELECT DRIVE 1" << endl;
createtxt << "SELECT PARTITION 2" << endl;
createtxt << "STORE WITH COMPRESSION HIGH" << endl;
createtxt.close();
printf("created PQDI file!\n");
char dgFile[12];
dgFile[0]=imgDrv;
dgFile[1]='\0';
strcat(dgFile,":\\dosgo.bat");
// create dosgo filestream
ofstream dosgo;
// open for ouput on dosgo.bat
dosgo.open(dgFile,ios: :out);
printf("Create image ran!\n");
dosgo << "c:\\pqdi.exe /cmd=%IMGDRV%:\\create.txt /img=%IMGDRV%:\\"
<< imgFile << " /I24 /IFC /NBS /NRB /ERR=%IMGDRV%:\\create.err /LOG=%IMGDRV%:\\create.log" << endl;
dosgo << "if exist %IMGDRV%:\\create.err goto IMGERR" << endl;
dosgo << "call %IMGDRV%:\\errorlog.bat 000 \"Created Image, restarting to Windows\" %IMGDRV%"<< endl;
dosgo << "goto DONE" << endl;
dosgo << ":IMGERR" << endl;
dosgo << "call %IMGDRV%:\\errorlog.bat 851 \"Error creating image file\" %IMGDRV%" << endl;
dosgo << " :DONE" << endl;
dosgo << "call c:\\setpdos.bat" << endl;
dosgo << "call c:\\setactiv.bat" << endl;
// dosgo.flush(); - you have to flush if you don't endl
dosgo.close();
printf("created dosgo file\n");
// the ftpput filestream to put image file
char ftpFile[13];
ftpFile[0]=imgDrv;
ftpFile[1]='\0';
strcat(ftpFile, ":\\ftpput.bat");
ofstream ftpput;
ftpput.open(ftpFile,ios: :out);
ftpput << "if exist " << imgDrv << ":\\ftpdoflg.flg goto :NOFTP" << endl;
ftpput << "c:\\ibm\\iaaconfig\\getfile " << ftpServer << " "
<< user << " " << passwd << " " << remotePath << " " << imgDrv
<< " " << remoteFile << " " << localFile << endl;
ftpput << "if errorlevel 1 goto FTPFAIL" << endl;
ftpput << "call " << imgDrv << ":\\errorlog.bat 000 \"Created file on FTP Server\""
<< imgDrv << endl;
ftpput << "call " << imgDrv << ":\\errorlog.bat 111 \"Create Image Complete\""
<< imgDrv << endl;
ftpput << "goto EXIT" << endl;
ftpput << ":FTPFAIL" << endl;
ftpput << "call " << imgDrv << ":\\errorlog.bat 805 \"Error creating file on FTP Server\" "
<< imgDrv << endl;
ftpput << "goto EXIT" << endl;
ftpput << ":NOFTP" << endl;
ftpput << "call " << imgDrv << ":\\errorlog.bat 000 \"Image created on this machine so not FTPing file up\" "
<< imgDrv << endl;
ftpput << ":EXIT" << endl;
ftpput << "call c:\\ibm\\iaaconfig\\clean.bat c:\\ibm\\iaaconfig "
<< imgDrv << endl;
ftpput.close();
printf("created dftp file\n");
// the autoexnt filestream for autoexnt.bat
string exntBuf = systemDir + "\\autoexnt.bat";
char* autoEXNTBat = new char[exntBuf.length()+1];
exntBuf.copy(autoEXNTBat, exntBuf.length());
*(autoEXNTBat + exntBuf.length()) = 0;
// create autoexnt.bat file
ofstream autoexntfile;
autoexntfile.open(autoEXNTBat,ios: :out);
autoexntfile << "if exist " << rlFlagStr << " call " << installDir
<< "\\restlogic.bat" << endl;
autoexntfile << "if exist " << ftpflag << " call " << installDir
<< "\\ftpput.bat" << endl;
autoexntfile.close();
printf("created autont file\n");
// now create flag files to enable restlogic operation
char* dorlFlg = new char[rlFlagStr.length()+1];
rlFlagStr.copy(dorlFlg, rlFlagStr.length());
*(dorlFlg + rlFlagStr.length()) = 0;
ofstream dorlFile;
dorlFile.open(dorlFlg,ios: :out);
dorlFile << "running restlogic" << endl;
dorlFile.close();
printf("created flag file\n");
}