I have quite a large text file, which I want to read into a wxTextCtrl. The catch is: This text file may change rapidly.
So I initially read in the whole file and append it to the textctrl:
Code: Select all
wxFile file;
file.Open(fn_logFile.GetFullPath());
file.ReadAll(&ms_fileContent);
ms_fileContent = ms_fileContent.ToUTF8();
mtc_log->AppendText(mLFC.ms_fileContent);
file.Close();
Now I want to update the textCtrl periodically.
I stored the length of my file
Code: Select all
wxFileOffset mfo_fileLength = file.Length()
Code: Select all
size_t sizeBufferDif = mfo_fileUpdateLength - file.Length();
if (sizeBufferDif <= 0)
{
return;
}
Code: Select all
ifstream a1;
a1.open("a.bin", ios::in|ios::binary)
char tmp[256]
a1.read(tmp,256)
a1.ignore(16); //THIS
a1.read(data, 256-16);
Reading in the whole file bit by bit takes at least some minutes, which is too long, let alone beeing repeated every 500ms:
Code: Select all
wxFileInputStream fis_input(mLFC.mfn_fileFullPath.GetFullPath());
wxTextInputStream tis_text(fis_input, wxT("\x0a"), wxConvUTF8);
wxString sNewContent;
wxChar* buffer = new wxChar[1024];
do
{
fis_input.Read(buffer, 1024 * sizeof(wxChar));
sNewContent.Append(buffer, 1024); //wxString& Append(const wchar_t *pwz, size_t nLen)
}
while (fis_input.LastRead() > 0);
wxMessageBox(sNewContent);
Natu