// An entry is considered a directory if it has a stored size of zero // and it ends with '/' or '\' character. staticbool isDirectory(ZipEntry* entry) { if (entry->getUncompressedLen() != 0) { returnfalse;
}
/* this mode isn't supported -- do a trivial check */ if (strcmp(inFileName, outFileName) == 0) {
fprintf(stderr, "Input and output can't be same file\n"); return1;
}
if (zin.open(inFileName, ZipFile::kOpenReadOnly) != OK) {
fprintf(stderr, "Unable to open '%s' as zip archive: %s\n", inFileName, strerror(errno)); return1;
} if (zout.open(outFileName,
ZipFile::kOpenReadWrite|ZipFile::kOpenCreate|ZipFile::kOpenTruncate)
!= OK)
{
fprintf(stderr, "Unable to open '%s' as zip archive\n", outFileName); return1;
}
int result = copyAndAlign(&zin, &zout, alignment, zopfli, pageAlignSharedLibs,
pageSize); if (result != 0) {
printf("zipalign: failed rewriting '%s' to '%s'\n",
inFileName, outFileName);
} return result;
}
/* *Verifythealignmentofaziparchive.
*/ int verify(constchar* fileName, int alignment, bool verbose, bool pageAlignSharedLibs, int pageSize)
{
ZipFile zipFile; bool foundBad = false;
if (verbose)
printf("Verifying alignment of %s (%d)...\n", fileName, alignment);
if (zipFile.open(fileName, ZipFile::kOpenReadOnly) != OK) {
fprintf(stderr, "Unable to open '%s' for verification\n", fileName); return1;
}
int numEntries = zipFile.getNumEntries();
ZipEntry* pEntry;
for (int i = 0; i < numEntries; i++) {
pEntry = zipFile.getEntryByIndex(i); if (pEntry->isCompressed()) { if (verbose) {
printf("%8jd %s (OK - compressed)\n",
(intmax_t) pEntry->getFileOffset(), pEntry->getFileName());
}
} elseif(isDirectory(pEntry)) { // Directory entries do not need to be aligned. if (verbose)
printf("%8jd %s (OK - directory)\n",
(intmax_t) pEntry->getFileOffset(), pEntry->getFileName()); continue;
} else {
off_t offset = pEntry->getFileOffset(); constint alignTo = getAlignment(pageAlignSharedLibs, alignment, pEntry,
pageSize); if ((offset % alignTo) != 0) { if (verbose) {
printf("%8jd %s (BAD - %jd)\n",
(intmax_t) offset, pEntry->getFileName(),
(intmax_t) (offset % alignTo));
}
foundBad = true;
} else { if (verbose) {
printf("%8jd %s (OK)\n",
(intmax_t) offset, pEntry->getFileName());
}
}
}
}
if (verbose)
printf("Verification %s\n", foundBad ? "FAILED" : "successful");
return foundBad ? 1 : 0;
}
} // namespace android
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet am 2026-06-28)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.