BOOL cWindow :: LoadFolder(std::string Folder)
{
std::string Result = "";
std::string Input = "";
int Read = 0;
std::fstream File;
std::ostringstream oss;
cButtonA *atr;
CFileSearch *Search = new CFileSearch(Folder + "*.txt");
while(Search->GetNext(Result))
{
oss << Folder << Result;
File.open(oss.str().c_str(), std::ios::in);
if (File.is_open())
{
while (std::getline(File, Input))
{
if (Input == "!!BUTTON!!")
{
atr = new cButtonA();
if (!ReadButton(atr,File,Read))
{
delete atr;
return Read;
}
AddButton(*atr, Folder);
delete atr;
}
}
}
else
{
File.close();
return NOFILE;
}
oss.str("");
File.close();
Input = "";
}
delete Search;
return SUCCESS;
}
std::fstream problem?
Well, i have some code that gets all the files in a folder, and goes thru them one at a time and loads data for files. But for some reason, it will read the first file ok, but not the second. It says that the file is opened but it never reads it. It messes up at the while (std::getline(File, Input);
Jake
From the a very brief glance of the code i don't see anything obvious so i'm going to take a stab in the dark and say call std::basic_ios::clear method after you've closed a file stream and before re-opening again. There is a known issue about iostream states not being reset after a file stream has been closed and reopened again.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement