strange issue with reading files...
rory
rorywalsh at gmail.com
Fri Jan 4 08:54:13 PST 2008
I've spent to whole day trying to figure out how do the following in a
wxwidget application:
1) open a binary file, an .exe to be precise,
2) read the last 10 chars from the end
3) offset the file by the value contained in those last 10 chars
4) retrieve everything from there till the end of the file.
I have it working without any problem in a non wxWidgets program but
as soon as I try to do it from my wx app it doesn't work. This is the
code I'm using:
std::string str, csdText;
char buf[10];
fstream inFile(appName.c_str());
if(!inFile) cerr << "Error";
inFile.seekg(-10, ios::end);
inFile.get(buf, sizeof(char)*10);
int pos = atoi(buf)+10;
wxMessageBox(buf);
inFile.seekg(-pos, ios::end);
csdText = "";
while(!inFile.eof()){
getline(inFile, str);
csdText = csdText+str;
}
wxMessageBox(csdText.c_str());
I've also tried with wxFile but I didn't have any joy with that
either. As a last resort I tried a straightforward C implementation
but that also fails with odd results. Can anyone see what the problem
might be, hopefully it is something silly I am overlooking. Please let
me know if you need any further info. I'm using wxWidgets 2.8. Cheers,
Rory.
More information about the wx-users
mailing list