| 2228 | } |
| 2229 | |
| 2230 | ssize_t AaptAssets::slurpResourceTree(Bundle* bundle, const String8& srcDir) |
| 2231 | { |
| 2232 | ssize_t err = 0; |
| 2233 | |
| 2234 | DIR* dir = opendir(srcDir.string()); |
| 2235 | if (dir == NULL) { |
| 2236 | fprintf(stderr, "ERROR: opendir(%s): %s\n", srcDir.string(), strerror(errno)); |
| 2237 | return UNKNOWN_ERROR; |
| 2238 | } |
| 2239 | |
| 2240 | status_t count = 0; |
| 2241 | |
| 2242 | /* |
| 2243 | * Run through the directory, looking for dirs that match the |
| 2244 | * expected pattern. |
| 2245 | */ |
| 2246 | while (1) { |
| 2247 | struct dirent* entry = readdir(dir); |
| 2248 | if (entry == NULL) { |
| 2249 | break; |
| 2250 | } |
| 2251 | |
| 2252 | if (isHidden(srcDir.string(), entry->d_name)) { |
| 2253 | continue; |
| 2254 | } |
| 2255 | |
| 2256 | String8 subdirName(srcDir); |
| 2257 | subdirName.appendPath(entry->d_name); |
| 2258 | |
| 2259 | AaptGroupEntry group; |
| 2260 | String8 resType; |
| 2261 | bool b = group.initFromDirName(entry->d_name, &resType); |
| 2262 | if (!b) { |
| 2263 | fprintf(stderr, "invalid resource directory name: %s/%s\n", srcDir.string(), |
| 2264 | entry->d_name); |
| 2265 | err = -1; |
| 2266 | continue; |
| 2267 | } |
| 2268 | |
| 2269 | if (bundle->getMaxResVersion() != NULL && group.getVersionString().length() != 0) { |
| 2270 | int maxResInt = atoi(bundle->getMaxResVersion()); |
| 2271 | const char *verString = group.getVersionString().string(); |
| 2272 | int dirVersionInt = atoi(verString + 1); // skip 'v' in version name |
| 2273 | if (dirVersionInt > maxResInt) { |
| 2274 | fprintf(stderr, "max res %d, skipping %s\n", maxResInt, entry->d_name); |
| 2275 | continue; |
| 2276 | } |
| 2277 | } |
| 2278 | |
| 2279 | FileType type = getFileType(subdirName.string()); |
| 2280 | |
| 2281 | if (type == kFileTypeDirectory) { |
| 2282 | sp<AaptDir> dir = makeDir(resType); |
| 2283 | ssize_t res = dir->slurpFullTree(bundle, subdirName, group, |
| 2284 | resType, mFullResPaths); |
| 2285 | if (res < 0) { |
| 2286 | count = res; |
| 2287 | goto bail; |
no test coverage detected