* Determine whether or not we want to try to compress this file based * on the file extension. */
| 627 | * on the file extension. |
| 628 | */ |
| 629 | bool okayToCompress(Bundle* bundle, const String8& pathName) |
| 630 | { |
| 631 | String8 ext = pathName.getPathExtension(); |
| 632 | int i; |
| 633 | |
| 634 | if (ext.length() == 0) |
| 635 | return true; |
| 636 | |
| 637 | for (i = 0; i < NELEM(kNoCompressExt); i++) { |
| 638 | if (strcasecmp(ext.string(), kNoCompressExt[i]) == 0) |
| 639 | return false; |
| 640 | } |
| 641 | |
| 642 | const android::Vector<const char*>& others(bundle->getNoCompressExtensions()); |
| 643 | for (i = 0; i < (int)others.size(); i++) { |
| 644 | const char* str = others[i]; |
| 645 | int pos = pathName.length() - strlen(str); |
| 646 | if (pos < 0) { |
| 647 | continue; |
| 648 | } |
| 649 | const char* path = pathName.string(); |
| 650 | if (strcasecmp(path + pos, str) == 0) { |
| 651 | return false; |
| 652 | } |
| 653 | } |
| 654 | |
| 655 | return true; |
| 656 | } |
| 657 | |
| 658 | bool endsWith(const char* haystack, const char* needle) |
| 659 | { |
no test coverage detected