| 835 | } |
| 836 | |
| 837 | bool CFileManager::UopLoadFile(CUopMappedFile &file, const char *uopFilename, bool dumpInfo) |
| 838 | { |
| 839 | auto path{ UOFilePath(uopFilename) }; |
| 840 | if (!fs_path_exists(path)) |
| 841 | { |
| 842 | return false; |
| 843 | } |
| 844 | |
| 845 | if (!file.Load(path)) |
| 846 | { |
| 847 | return false; |
| 848 | } |
| 849 | |
| 850 | const char *filename = fs_path_ascii(path); |
| 851 | DEBUG(Data, "loading UOP: %s", filename); |
| 852 | file.Header = (UopHeader *)file.Start; |
| 853 | if (file.Header->Magic != MYP_MAGIC) |
| 854 | { |
| 855 | Error(Data, "%s:unknown file format 0x%08x", filename, file.Header->Magic); |
| 856 | return false; |
| 857 | } |
| 858 | |
| 859 | if (file.Header->Version > 5) |
| 860 | { |
| 861 | Warning(Data, "%s:unexpected version %d", filename, file.Header->Version); |
| 862 | } |
| 863 | TRACE(Data, "%s:signature is 0x%08x", filename, file.Header->Signature); |
| 864 | TRACE(Data, "%s:file_count is %d", filename, file.Header->FileCount); |
| 865 | |
| 866 | dumpInfo = dumpInfo || (g_dumpUopFile.compare(uopFilename) == 0); |
| 867 | |
| 868 | file.ResetPtr(); |
| 869 | uint64_t next = file.Header->SectionOffset; |
| 870 | file.Move(checked_cast<intptr_t>(next)); |
| 871 | do |
| 872 | { |
| 873 | auto section = (UopSection *)file.Ptr; |
| 874 | file.Move(sizeof(UopSection)); |
| 875 | |
| 876 | for (uint32_t i = 0; i < section->FileCount; i++) |
| 877 | { |
| 878 | auto entry = (UopFileEntry *)file.Ptr; |
| 879 | file.Move(sizeof(UopFileEntry)); |
| 880 | if (entry->Offset == 0) |
| 881 | { |
| 882 | continue; |
| 883 | } |
| 884 | file.AddAsset(entry); |
| 885 | } |
| 886 | next = section->NextSection; |
| 887 | file.ResetPtr(); |
| 888 | file.Move(checked_cast<intptr_t>(next)); |
| 889 | } while (next != 0); |
| 890 | file.ResetPtr(); |
| 891 | |
| 892 | if (dumpInfo) |
| 893 | { |
| 894 | std::sort(file.m_NameHashes.begin(), file.m_NameHashes.end()); |
no test coverage detected