MCPcopy Create free account
hub / github.com/defold/defold / MountArchiveInternal

Function MountArchiveInternal

engine/resource/src/mount/mount_android.cpp:130–221  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

128 }
129
130 Result MountArchiveInternal(const char* index_path, const char* data_path, dmResourceArchive::HArchiveIndexContainer* archive, void** mount_info)
131 {
132 AAsset* index_asset = 0x0;
133 uint32_t index_length = 0;
134 void* index_map = 0x0;
135 AAsset* data_asset = 0x0;
136 uint32_t data_length = 0;
137 void* data_map = 0x0;
138
139 Result r;
140
141 // Map data asset (if bundled) or file (if in local storage)
142 bool mem_mapped_data = false;
143 if (strcmp(data_path, "game.arcd") == 0)
144 {
145 r = MapAsset(data_path, (void*&)data_asset, data_length, data_map);
146 if (r != RESULT_OK)
147 {
148 dmLogError("Error when mapping data file '%s', result = %i", data_path, r);
149 return RESULT_IO_ERROR;
150 }
151 } else
152 {
153 r = MapFile(data_path, data_map, data_length);
154 if (r != RESULT_OK)
155 {
156 dmLogError("Error mapping liveupdate data file, result = %i", r);
157 return RESULT_IO_ERROR;
158 }
159 mem_mapped_data = true;
160 }
161
162 // Map index asset (if bundled) or file (if in local storage)
163 bool mem_mapped_index = false;
164 if (strcmp(index_path, "game.arci") == 0)
165 {
166 r = MapAsset(index_path, (void*&)index_asset, index_length, index_map);
167 if (r != RESULT_OK)
168 {
169 if (mem_mapped_data)
170 UnmapFile(data_map, data_length);
171 else
172 UnmapAsset((void*&)data_asset, data_length);
173 dmLogError("Error when mapping index file, result: %i", r);
174 return RESULT_IO_ERROR;
175 }
176 }
177 else
178 {
179 r = MapFile(index_path, index_map, index_length);
180 if (r != RESULT_OK)
181 {
182 if (mem_mapped_data)
183 UnmapFile(data_map, data_length);
184 else
185 UnmapAsset((void*&)data_asset, data_length);
186 dmLogError("Error mapping liveupdate index file, result = %i", r);
187 return RESULT_IO_ERROR;

Callers

nothing calls this directly

Calls 5

WrapArchiveBufferFunction · 0.85
MapAssetFunction · 0.70
MapFileFunction · 0.70
UnmapFileFunction · 0.70
UnmapAssetFunction · 0.70

Tested by

no test coverage detected