MCPcopy Create free account
hub / github.com/CyanogenMod/android_frameworks_base / addAssetPath

Method addAssetPath

libs/androidfw/AssetManager.cpp:199–251  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197}
198
199bool AssetManager::addAssetPath(const String8& path, void** cookie)
200{
201 AutoMutex _l(mLock);
202
203 asset_path ap;
204
205 String8 realPath(path);
206 if (kAppZipName) {
207 realPath.appendPath(kAppZipName);
208 }
209 ap.type = ::getFileType(realPath.string());
210 if (ap.type == kFileTypeRegular) {
211 ap.path = realPath;
212 } else {
213 ap.path = path;
214 ap.type = ::getFileType(path.string());
215 if (ap.type != kFileTypeDirectory && ap.type != kFileTypeRegular) {
216 ALOGW("Asset path %s is neither a directory nor file (type=%d).",
217 path.string(), (int)ap.type);
218 return false;
219 }
220 }
221
222 // Skip if we have it already.
223 for (size_t i=0; i<mAssetPaths.size(); i++) {
224 if (mAssetPaths[i].path == ap.path) {
225 if (cookie) {
226 *cookie = (void*)(i+1);
227 }
228 return true;
229 }
230 }
231
232 ALOGV("In %p Asset %s path: %s", this,
233 ap.type == kFileTypeDirectory ? "dir" : "zip", ap.path.string());
234
235 mAssetPaths.add(ap);
236
237 // new paths are always added at the end
238 if (cookie) {
239 *cookie = (void*)mAssetPaths.size();
240 }
241
242#ifdef HAVE_ANDROID_OS
243 // Load overlays, if any
244 asset_path oap;
245 for (size_t idx = 0; mZipSet.getOverlay(ap.path, idx, &oap); idx++) {
246 mAssetPaths.add(oap);
247 }
248#endif
249
250 return true;
251}
252
253
254/*

Callers 5

hasCommonResourcesMethod · 0.95
doListFunction · 0.45
doDumpFunction · 0.45
parseFromZipMethod · 0.45

Calls 6

appendPathMethod · 0.80
stringMethod · 0.80
getFileTypeFunction · 0.70
sizeMethod · 0.65
addMethod · 0.65
getOverlayMethod · 0.45

Tested by

no test coverage detected