+ output << tmp;
+ linelng += tmp.Length()+1;
+ }
+
+ delete[] buffer;
+
+ output += _T("};\n\n");
+
+ return output;
+}
+
+
+void XmlResApp::MakePackageCPP(const wxArrayString& flist)
+{
+ wxFFile file(parOutput, wxT("wt"));
+ size_t i;
+
+ if (flagVerbose)
+ wxPrintf(_T("creating C++ source file ") + parOutput + _T("...\n"));
+
+ file.Write(_T("")
+_T("//\n")
+_T("// This file was automatically generated by wxrc, do not edit by hand.\n")
+_T("//\n\n")
+_T("#include <wx/wxprec.h>\n")
+_T("\n")
+_T("#ifdef __BORLANDC__\n")
+_T(" #pragma hdrstop\n")
+_T("#endif\n")
+_T("\n")
+_T("")
+_T("#include <wx/filesys.h>\n")
+_T("#include <wx/fs_mem.h>\n")
+_T("#include <wx/xrc/xmlres.h>\n")
+_T("#include <wx/xrc/xh_all.h>\n")
+_T("\n"));
+
+ for (i = 0; i < flist.Count(); i++)
+ file.Write(
+ FileToCppArray(parOutputPath + wxFILE_SEP_PATH + flist[i], i));
+
+ file.Write(_T("")
+_T("void ") + parFuncname + wxT("()\n")
+_T("{\n")
+_T("\n")
+_T(" // Check for memory FS. If not present, load the handler:\n")
+_T(" {\n")
+_T(" wxMemoryFSHandler::AddFile(wxT(\"XRC_resource/dummy_file\"), wxT(\"dummy one\"));\n")
+_T(" wxFileSystem fsys;\n")
+_T(" wxFSFile *f = fsys.OpenFile(wxT(\"memory:XRC_resource/dummy_file\"));\n")
+_T(" wxMemoryFSHandler::RemoveFile(wxT(\"XRC_resource/dummy_file\"));\n")
+_T(" if (f) delete f;\n")
+_T(" else wxFileSystem::AddHandler(new wxMemoryFSHandler);\n")
+_T(" }\n")
+_T("\n"));
+
+ for (i = 0; i < flist.Count(); i++)
+ {
+ wxString s;
+ s.Printf(_T(" wxMemoryFSHandler::AddFile(wxT(\"XRC_resource/") + flist[i] +
+ _T("\"), xml_res_file_%i, xml_res_size_%i);\n"), i, i);
+ file.Write(s);
+ }
+
+ for (i = 0; i < parFiles.Count(); i++)
+ {
+ file.Write(_T(" wxXmlResource::Get()->Load(wxT(\"memory:XRC_resource/") +
+ GetInternalFileName(parFiles[i], flist) + _T("\"));\n"));
+ }
+
+ file.Write(_T("}\n"));
+
+
+}
+
+void XmlResApp::GenCPPHeader()
+{
+ wxString fileSpec = ((parOutput.BeforeLast('.')).AfterLast('/')).AfterLast('\\');
+ wxString heaFileName = fileSpec + _T(".h");
+
+ wxFFile file(heaFileName, wxT("wt"));
+ file.Write(
+_T("//\n")
+_T("// This file was automatically generated by wxrc, do not edit by hand.\n")
+_T("//\n\n")
+_T("#ifndef __") + fileSpec + _T("_h__\n")
+_T("#define __") + fileSpec + _T("_h__\n")
+);
+ for(size_t i=0;i<aXRCWndClassData.Count();++i){
+ aXRCWndClassData.Item(i).GenerateHeaderCode(file);
+ }
+ file.Write(
+ _T("\nvoid \n")
+ + parFuncname
+ + _T("();\n#endif\n"));
+}
+
+static wxString FileToPythonArray(wxString filename, int num)
+{
+ wxString output;
+ wxString tmp;
+ wxString snum;
+ wxFFile file(filename, wxT("rb"));
+ wxFileOffset offset = file.Length();
+ wxASSERT_MSG( offset >= 0 , wxT("Invalid file length") );
+
+ const size_t lng = wx_truncate_cast(size_t, offset);
+ wxASSERT_MSG( offset == lng, wxT("Huge file not supported") );
+
+ snum.Printf(_T("%i"), num);
+ output = _T(" xml_res_file_") + snum + _T(" = '''\\\n");
+
+ unsigned char *buffer = new unsigned char[lng];
+ file.Read(buffer, lng);
+
+ for (size_t i = 0, linelng = 0; i < lng; i++)
+ {
+ unsigned char c = buffer[i];
+ if (c == '\n')