| 8 | void CXml::ClearInternal() { m_Doc.Clear(); } |
| 9 | |
| 10 | void ParseFile(LPCSTR path, CMemoryWriter& W, IReader* F, CXml* xml, LPCSTR current_xml_filename) |
| 11 | { |
| 12 | xr_string str; |
| 13 | |
| 14 | const auto loadFile = [&](LPCSTR file_name) { |
| 15 | IReader* I = nullptr; |
| 16 | |
| 17 | if (file_name == strstr(file_name, "ui\\")) |
| 18 | { |
| 19 | shared_str fn = xml->correct_file_name("ui", strchr(file_name, '\\') + 1); |
| 20 | string_path buff; |
| 21 | strconcat(sizeof(buff), buff, "ui\\", fn.c_str()); |
| 22 | I = FS.r_open(path, buff); |
| 23 | } |
| 24 | |
| 25 | if (!I) |
| 26 | { |
| 27 | I = FS.r_open(path, file_name); |
| 28 | } |
| 29 | |
| 30 | if (!I) |
| 31 | { |
| 32 | string1024 str; |
| 33 | xr_sprintf(str, "XML file[%s] parsing failed. Can't find include file:[%s]", path, file_name); |
| 34 | R_ASSERT(false, str); |
| 35 | } |
| 36 | |
| 37 | I->skip_bom(file_name); |
| 38 | |
| 39 | ParseFile(path, W, I, xml, file_name); |
| 40 | FS.r_close(I); |
| 41 | }; |
| 42 | |
| 43 | while (!F->eof()) |
| 44 | { |
| 45 | F->r_string(str); |
| 46 | |
| 47 | if (str[0] && (str[0] == '#') && strstr(str.c_str(), "#include")) |
| 48 | { |
| 49 | if (string256 inc_name; _GetItem(str.c_str(), 1, inc_name, '"')) |
| 50 | { |
| 51 | if (strstr(inc_name, "*.xml")) |
| 52 | { |
| 53 | FS_FileSet fset; |
| 54 | FS.file_list(fset, path, FS_ListFiles, inc_name); |
| 55 | |
| 56 | for (FS_FileSet::iterator it = fset.begin(); it != fset.end(); it++) |
| 57 | { |
| 58 | LPCSTR file_name = it->name.c_str(); |
| 59 | |
| 60 | if (strcmp(current_xml_filename, file_name) == 0) |
| 61 | continue; |
| 62 | |
| 63 | loadFile(file_name); |
| 64 | } |
| 65 | } |
| 66 | else |
| 67 | { |