| 29 | } |
| 30 | |
| 31 | bool BeLibFile::ReadLib() |
| 32 | { |
| 33 | BP_ZONE("BeLibFile::ReadLib"); |
| 34 | |
| 35 | char fileId[8]; |
| 36 | mOldFileStream.Read(fileId, 8); |
| 37 | if (strncmp(fileId, "!<arch>\n", 8) != 0) |
| 38 | return false; |
| 39 | |
| 40 | const char* libStrTable = NULL; |
| 41 | |
| 42 | Dictionary<int, BeLibEntry*> pendingLibEntryMap; |
| 43 | |
| 44 | int memberIdx = 0; |
| 45 | while (true) |
| 46 | { |
| 47 | int headerFilePos = mOldFileStream.GetPos(); |
| 48 | |
| 49 | BeLibMemberHeader header; |
| 50 | mOldFileStream.Read(&header, sizeof(header)); |
| 51 | if (mOldFileStream.mReadPastEnd) |
| 52 | break; |
| 53 | |
| 54 | int len = atoi(header.mSize); |
| 55 | |
| 56 | if (strncmp(header.mName, "/ ", 2) == 0) |
| 57 | { |
| 58 | if (memberIdx == 0) |
| 59 | { |
| 60 | uint8* data = new uint8[len]; |
| 61 | mOldFileStream.Read(data, len); |
| 62 | |
| 63 | int numSymbols = FromBigEndian(*(int32*)data); |
| 64 | |
| 65 | uint8* strTab = data + 4 + numSymbols * 4; |
| 66 | |
| 67 | for (int symIdx = 0; symIdx < numSymbols; symIdx++) |
| 68 | { |
| 69 | const char* str = (char*)strTab; |
| 70 | strTab += strlen((char*)strTab) + 1; |
| 71 | |
| 72 | int offset = FromBigEndian(((int32*)(data + 4))[symIdx]); |
| 73 | |
| 74 | BeLibEntry* pendingEntry; |
| 75 | |
| 76 | BeLibEntry** pendingEntryPtr = NULL; |
| 77 | if (!pendingLibEntryMap.TryAdd(offset, NULL, &pendingEntryPtr)) |
| 78 | { |
| 79 | pendingEntry = *pendingEntryPtr; |
| 80 | } |
| 81 | else |
| 82 | { |
| 83 | pendingEntry = new BeLibEntry(); |
| 84 | pendingEntry->mLibFile = this; |
| 85 | *pendingEntryPtr = pendingEntry; |
| 86 | } |
| 87 | |
| 88 | pendingEntry->mSymbols.push_back(str); |
nothing calls this directly
no test coverage detected