looking for wxTextInputStream replacement for binary files
Posted: Mon Apr 20, 2020 7:29 pm
Hello there,
I am looking a piece of code to replace wxTextInputStream to something for binary data.
I don't understand how to use wxMemoryBuffer. Please advice.
In resources there are the following files: ChartNew.js, format.js, home_page.htt, kaching.wav, master.css, mmex.ico, sorttable.js
Thanks in advance
I am looking a piece of code to replace wxTextInputStream to something for binary data.
I don't understand how to use wxMemoryBuffer. Please advice.
In resources there are the following files: ChartNew.js, format.js, home_page.htt, kaching.wav, master.css, mmex.ico, sorttable.js
Thanks in advance
Code: Select all
//Read files from resources
const wxString res_dir = mmex::GetResourceDir().GetPathWithSep();
wxArrayString files_array;
wxDir::GetAllFiles(res_dir, &files_array);
for (const auto& source_file : files_array)
{
wxString data;
if (wxFileName::FileExists(source_file))
{
wxFileInputStream input(source_file);
wxTextInputStream text(input);
while (input.IsOk() && !input.Eof()) {
data += text.ReadLine() + "\n";
}
const auto file_name = wxFileName(source_file).GetFullName();
wxLogDebug("File: %s has been copied to VFS", file_name);
wxMemoryFSHandler::AddFile(file_name, data);
}
}