| 265 | // ========================================================================== |
| 266 | |
| 267 | static status_t makeFileResources(Bundle* bundle, const sp<AaptAssets>& assets, |
| 268 | ResourceTable* table, |
| 269 | const sp<ResourceTypeSet>& set, |
| 270 | const char* resType) |
| 271 | { |
| 272 | String8 type8(resType); |
| 273 | String16 type16(resType); |
| 274 | |
| 275 | bool hasErrors = false; |
| 276 | |
| 277 | ResourceDirIterator it(set, String8(resType)); |
| 278 | ssize_t res; |
| 279 | while ((res=it.next()) == NO_ERROR) { |
| 280 | if (bundle->getVerbose()) { |
| 281 | printf(" (new resource id %s from %s)\n", |
| 282 | it.getBaseName().string(), it.getFile()->getPrintableSource().string()); |
| 283 | } |
| 284 | String16 baseName(it.getBaseName()); |
| 285 | const char16_t* str = baseName.string(); |
| 286 | const char16_t* const end = str + baseName.size(); |
| 287 | while (str < end) { |
| 288 | if (!((*str >= 'a' && *str <= 'z') |
| 289 | || (*str >= '0' && *str <= '9') |
| 290 | || *str == '_' || *str == '.')) { |
| 291 | fprintf(stderr, "%s: Invalid file name: must contain only [a-z0-9_.]\n", |
| 292 | it.getPath().string()); |
| 293 | hasErrors = true; |
| 294 | } |
| 295 | str++; |
| 296 | } |
| 297 | String8 resPath = it.getPath(); |
| 298 | resPath.convertToResPath(); |
| 299 | table->addEntry(SourcePos(it.getPath(), 0), String16(assets->getPackage()), |
| 300 | type16, |
| 301 | baseName, |
| 302 | String16(resPath), |
| 303 | NULL, |
| 304 | &it.getParams()); |
| 305 | assets->addResource(it.getLeafName(), resPath, it.getFile(), type8); |
| 306 | } |
| 307 | |
| 308 | return hasErrors ? UNKNOWN_ERROR : NO_ERROR; |
| 309 | } |
| 310 | |
| 311 | class PreProcessImageWorkUnit : public WorkQueue::WorkUnit { |
| 312 | public: |
no test coverage detected