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

Function doList

tools/aapt/Command.cpp:123–228  ·  view source on GitHub ↗

* Handle the "list" command, which can be a simple file dump or * a verbose listing. * * The verbose listing closely matches the output of the Info-ZIP "unzip" * command. */

Source from the content-addressed store, hash-verified

121 * command.
122 */
123int doList(Bundle* bundle)
124{
125 int result = 1;
126 ZipFile* zip = NULL;
127 const ZipEntry* entry;
128 long totalUncLen, totalCompLen;
129 const char* zipFileName;
130
131 if (bundle->getFileSpecCount() != 1) {
132 fprintf(stderr, "ERROR: specify zip file name (only)\n");
133 goto bail;
134 }
135 zipFileName = bundle->getFileSpecEntry(0);
136
137 zip = openReadOnly(zipFileName);
138 if (zip == NULL)
139 goto bail;
140
141 int count, i;
142
143 if (bundle->getVerbose()) {
144 printf("Archive: %s\n", zipFileName);
145 printf(
146 " Length Method Size Ratio Offset Date Time CRC-32 Name\n");
147 printf(
148 "-------- ------ ------- ----- ------- ---- ---- ------ ----\n");
149 }
150
151 totalUncLen = totalCompLen = 0;
152
153 count = zip->getNumEntries();
154 for (i = 0; i < count; i++) {
155 entry = zip->getEntryByIndex(i);
156 if (bundle->getVerbose()) {
157 char dateBuf[32];
158 time_t when;
159
160 when = entry->getModWhen();
161 strftime(dateBuf, sizeof(dateBuf), "%m-%d-%y %H:%M",
162 localtime(&when));
163
164 printf("%8ld %-7.7s %7ld %3d%% %8zd %s %08lx %s\n",
165 (long) entry->getUncompressedLen(),
166 compressionName(entry->getCompressionMethod()),
167 (long) entry->getCompressedLen(),
168 calcPercent(entry->getUncompressedLen(),
169 entry->getCompressedLen()),
170 (size_t) entry->getLFHOffset(),
171 dateBuf,
172 entry->getCRC32(),
173 entry->getFileName());
174 } else {
175 printf("%s\n", entry->getFileName());
176 }
177
178 totalUncLen += entry->getUncompressedLen();
179 totalCompLen += entry->getCompressedLen();
180 }

Callers 1

handleCommandFunction · 0.85

Calls 15

openReadOnlyFunction · 0.85
compressionNameFunction · 0.85
calcPercentFunction · 0.85
printXMLBlockFunction · 0.85
getFileSpecCountMethod · 0.80
getFileSpecEntryMethod · 0.80
getVerboseMethod · 0.80
getEntryByIndexMethod · 0.80
getModWhenMethod · 0.80
getUncompressedLenMethod · 0.80
getCompressedLenMethod · 0.80
getLFHOffsetMethod · 0.80

Tested by

no test coverage detected