| 100 | } |
| 101 | |
| 102 | Result MountArchiveInternal(const char* index_path, const char* data_path, dmResourceArchive::HArchiveIndexContainer* archive, void** mount_info) |
| 103 | { |
| 104 | void* index_map = 0x0; |
| 105 | uint32_t index_size = 0; |
| 106 | Result r = MapFile(index_path, index_map, index_size); |
| 107 | if (r != RESULT_OK) |
| 108 | { |
| 109 | dmLogError("Error when mapping index file, result: %i", r); |
| 110 | return r; |
| 111 | } |
| 112 | |
| 113 | void* data_map = 0x0; |
| 114 | uint32_t data_size = 0; |
| 115 | r = MapFile(data_path, data_map, data_size); |
| 116 | if (r != RESULT_OK) |
| 117 | { |
| 118 | munmap(index_map, index_size); |
| 119 | dmLogError("Error when mapping data file '%s', result = %i", data_path, r); |
| 120 | return r; |
| 121 | } |
| 122 | |
| 123 | dmResourceArchive::Result res = WrapArchiveBuffer(index_map, index_size, true, |
| 124 | data_map, data_size, true, |
| 125 | archive); |
| 126 | if (res != dmResourceArchive::RESULT_OK) |
| 127 | { |
| 128 | munmap(index_map, index_size); |
| 129 | munmap(data_map, data_size); |
| 130 | if (res == dmResourceArchive::RESULT_VERSION_MISMATCH) |
| 131 | return RESULT_VERSION_MISMATCH; |
| 132 | return RESULT_IO_ERROR; |
| 133 | } |
| 134 | |
| 135 | MountInfo* info = new MountInfo(); |
| 136 | info->index_map = index_map; |
| 137 | info->index_length = index_size; |
| 138 | info->data_map = data_map; |
| 139 | info->data_length = data_size; |
| 140 | *mount_info = (void*)info; |
| 141 | |
| 142 | return RESULT_OK; |
| 143 | } |
| 144 | |
| 145 | void UnmountArchiveInternal(dmResourceArchive::HArchiveIndexContainer &archive, void* mount_info) |
| 146 | { |
no test coverage detected