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

Method crunch

tools/aapt/CrunchCache.cpp:31–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29}
30
31size_t CrunchCache::crunch(CacheUpdater* cu, bool forceOverwrite)
32{
33 size_t numFilesUpdated = 0;
34
35 // Iterate through the source files and compare to cache.
36 // After processing a file, remove it from the source files and
37 // from the dest files.
38 // We're done when we're out of files in source.
39 String8 relativePath;
40 while (mSourceFiles.size() > 0) {
41 // Get the full path to the source file, then convert to a c-string
42 // and offset our beginning pointer to the length of the sourcePath
43 // This efficiently strips the source directory prefix from our path.
44 // Also, String8 doesn't have a substring method so this is what we've
45 // got to work with.
46 const char* rPathPtr = mSourceFiles.keyAt(0).string()+mSourcePath.length();
47 // Strip leading slash if present
48 int offset = 0;
49 if (rPathPtr[0] == OS_PATH_SEPARATOR)
50 offset = 1;
51 relativePath = String8(rPathPtr + offset);
52
53 if (forceOverwrite || needsUpdating(relativePath)) {
54 cu->processImage(mSourcePath.appendPathCopy(relativePath),
55 mDestPath.appendPathCopy(relativePath));
56 numFilesUpdated++;
57 // crunchFile(relativePath);
58 }
59 // Delete this file from the source files and (if it exists) from the
60 // dest files.
61 mSourceFiles.removeItemsAt(0);
62 mDestFiles.removeItem(mDestPath.appendPathCopy(relativePath));
63 }
64
65 // Iterate through what's left of destFiles and delete leftovers
66 while (mDestFiles.size() > 0) {
67 cu->deleteFile(mDestFiles.keyAt(0));
68 mDestFiles.removeItemsAt(0);
69 }
70
71 // Update our knowledge of the files cache
72 // both source and dest should be empty by now.
73 loadFiles();
74
75 return numFilesUpdated;
76}
77
78void CrunchCache::loadFiles()
79{

Callers 2

updatePreProcessedCacheFunction · 0.45
mainFunction · 0.45

Calls 8

stringMethod · 0.80
removeItemsAtMethod · 0.80
sizeMethod · 0.65
removeItemMethod · 0.65
keyAtMethod · 0.45
lengthMethod · 0.45
processImageMethod · 0.45
deleteFileMethod · 0.45

Tested by 1

mainFunction · 0.36