Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void GAFactory::BuildXMLFIles(void)
- {
- // Get File Sysstem
- FileSystem * currentFileSystem = g_pApp->GetFileSystem();
- // Get filesystem directory
- String currentPath = currentFileSystem->GetProgramDir()+"GameData/";
- String fullPath = currentPath+String("Models/");
- String fullPath2 = currentPath+String("GameAssets/");
- Vector<String> FilesList;
- // Get Files
- currentFileSystem->ScanDir(FilesList, fullPath, "*.mdl", SCAN_FILES, false);
- // if siles appeared
- if(FilesList.Size()==0)
- {
- URHO3D_LOGINFO("No models in directory file");
- return ;
- }
- /// Template
- String TemplateFile = fullPath2+String("TemplateEngineObject.txt");
- /// Flag file for loading and load
- File templateLoadFile(context_, TemplateFile, FILE_READ);
- String * TemplateContent = new String();
- /// Read a template file
- if (templateLoadFile.GetSize()!=0)
- {
- char * stringmemory = new char(templateLoadFile.GetSize());
- templateLoadFile.Read(stringmemory,templateLoadFile.GetSize());
- TemplateContent->Append(String(stringmemory));
- }
- else
- {
- URHO3D_LOGINFO("No template file");
- return;
- }
- // loop through each and replate a new templatefile with code
- // loop through each file listing
- for(unsigned int fileListing = 0; fileListing<FilesList.Size(); fileListing++)
- {
- String newFilename = FilesList.At(fileListing);
- newFilename.Replace(".mdl",".xml", false);
- /// Template
- String NewResourceFilePath = fullPath2+String("/")+newFilename;
- /// Flag file for loading and load
- File NewResourceFile(context_, NewResourceFilePath, FILE_WRITE);
- // Copy template
- String CopyTemplate;
- CopyTemplate.Append(TemplateContent->CString());
- // Replace
- String StrippedName = FilesList.At(fileListing);
- StrippedName.Replace(".mdl","",false);
- CopyTemplate.Replace("##1##", StrippedName, true);
- CopyTemplate.Replace("##2##",FilesList.At(fileListing), true);
- // Replace Code
- NewResourceFile.Write(CopyTemplate.CString(), CopyTemplate.Length());
- NewResourceFile.Close();
- }
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment