Hi,
this is probably really easy but I don't know how to do it. I have a piece of code that opens a file and reads it's contents. The first time I open the file this code works fine - the second time it doesn't. I have checked all my opens and they all have matching close's.
My question is this. How do I get more information on why the file failed to open? Any help would be very much appreciated.
Here is some of my code if that's any help:
ifstream iniFileStream(REASONS_INI_FILE_NAME.c_str());
if (iniFileStream.is_open())
{
sprintf(log_msg, "SignDocInterface.cpp: opened reasons.ini file \n");
log();
char buffer[255];
for(index = 1; !iniFileStream.eof(); index++)
{
iniFileStream.getline(buffer, sizeof(buffer));
entryRef = sADMList->InsertEntry (listRef, index);
sADMEntry->SetText (entryRef, buffer);
sADMEntry->Select (entryRef, true);
}
}
else
{
// TODO: 2nd time we open dialog we get this message - Why???????????
sprintf(log_msg, "SignDocInterface.cpp: Failed to open reasons.ini file \n");
log();
}
sprintf(log_msg, "SignDocInterface.cpp: Closing reasons.ini file \n");
log();
iniFileStream.close();
this is probably really easy but I don't know how to do it. I have a piece of code that opens a file and reads it's contents. The first time I open the file this code works fine - the second time it doesn't. I have checked all my opens and they all have matching close's.
My question is this. How do I get more information on why the file failed to open? Any help would be very much appreciated.
Here is some of my code if that's any help:
ifstream iniFileStream(REASONS_INI_FILE_NAME.c_str());
if (iniFileStream.is_open())
{
sprintf(log_msg, "SignDocInterface.cpp: opened reasons.ini file \n");
log();
char buffer[255];
for(index = 1; !iniFileStream.eof(); index++)
{
iniFileStream.getline(buffer, sizeof(buffer));
entryRef = sADMList->InsertEntry (listRef, index);
sADMEntry->SetText (entryRef, buffer);
sADMEntry->Select (entryRef, true);
}
}
else
{
// TODO: 2nd time we open dialog we get this message - Why???????????
sprintf(log_msg, "SignDocInterface.cpp: Failed to open reasons.ini file \n");
log();
}
sprintf(log_msg, "SignDocInterface.cpp: Closing reasons.ini file \n");
log();
iniFileStream.close();