| 1753 | } |
| 1754 | |
| 1755 | ssize_t AaptDir::slurpFullTree(Bundle* bundle, const String8& srcDir, |
| 1756 | const AaptGroupEntry& kind, const String8& resType, |
| 1757 | sp<FilePathStore>& fullResPaths) |
| 1758 | { |
| 1759 | Vector<String8> fileNames; |
| 1760 | { |
| 1761 | DIR* dir = NULL; |
| 1762 | |
| 1763 | dir = opendir(srcDir.string()); |
| 1764 | if (dir == NULL) { |
| 1765 | fprintf(stderr, "ERROR: opendir(%s): %s\n", srcDir.string(), strerror(errno)); |
| 1766 | return UNKNOWN_ERROR; |
| 1767 | } |
| 1768 | |
| 1769 | /* |
| 1770 | * Slurp the filenames out of the directory. |
| 1771 | */ |
| 1772 | while (1) { |
| 1773 | struct dirent* entry; |
| 1774 | |
| 1775 | entry = readdir(dir); |
| 1776 | if (entry == NULL) |
| 1777 | break; |
| 1778 | |
| 1779 | if (isHidden(srcDir.string(), entry->d_name)) |
| 1780 | continue; |
| 1781 | |
| 1782 | String8 name(entry->d_name); |
| 1783 | fileNames.add(name); |
| 1784 | // Add fully qualified path for dependency purposes |
| 1785 | // if we're collecting them |
| 1786 | if (fullResPaths != NULL) { |
| 1787 | fullResPaths->add(srcDir.appendPathCopy(name)); |
| 1788 | } |
| 1789 | } |
| 1790 | closedir(dir); |
| 1791 | } |
| 1792 | |
| 1793 | ssize_t count = 0; |
| 1794 | |
| 1795 | /* |
| 1796 | * Stash away the files and recursively descend into subdirectories. |
| 1797 | */ |
| 1798 | const size_t N = fileNames.size(); |
| 1799 | size_t i; |
| 1800 | for (i = 0; i < N; i++) { |
| 1801 | String8 pathName(srcDir); |
| 1802 | FileType type; |
| 1803 | |
| 1804 | pathName.appendPath(fileNames[i].string()); |
| 1805 | type = getFileType(pathName.string()); |
| 1806 | if (type == kFileTypeDirectory) { |
| 1807 | sp<AaptDir> subdir; |
| 1808 | bool notAdded = false; |
| 1809 | if (mDirs.indexOfKey(fileNames[i]) >= 0) { |
| 1810 | subdir = mDirs.valueFor(fileNames[i]); |
| 1811 | } else { |
| 1812 | subdir = new AaptDir(fileNames[i], mPath.appendPathCopy(fileNames[i])); |
no test coverage detected