📄 stafzipcentraldir.cpp
字号:
+ "Error in checking data integrity: uPosFound [" + uPosFound + "] central dir offset [" + cder->centralDirOffset + "] central dir size [" + cder->centralDirSize + "].\n"; rc = kZIPGeneralZipError; } if (rc != kSTAFOk) { if ((*result).length() == 0) { *result = STAFString("STAFZipCentralDir::readInData: ") + "Error reading central dir end record.\n"; } return rc; } // move to central dir if (fseek(zf, cder->centralDirOffset + startPos, SEEK_SET) != 0) { *result = STAFString("STAFZipCentralDir::readInData: ") + "Error fseek central dir offset [" + cder->centralDirOffset + "].\n"; return kZIPGeneralZipError; } // get file headers for(int i = 0; i < cder->numberEntry; i++) { STAFZipFileHeader *fh = new STAFZipFileHeader(); // get signature rc = util.getLong(zf, &fh->signature); STAFTrace::trace(kSTAFTraceServiceResult, STAFString("STAFZipCentralDir::readInData_CP24") + " signature [" + fh->signature + "]"); // get version made by if (rc == kSTAFOk) { uLong iL; rc = util.getShort(zf, &iL); fh->versionMadeBy = (unsigned short)iL; STAFTrace::trace(kSTAFTraceServiceResult, STAFString("STAFZipCentralDir::readInData_CP25") + " versionMadeBy [" + fh->versionMadeBy + "]"); } // get version needed to extract if (rc == kSTAFOk) { uLong iL; rc = util.getShort(zf, &iL); fh->versionNeededToExtract = (unsigned short)iL; STAFTrace::trace(kSTAFTraceServiceResult, STAFString("STAFZipCentralDir::readInData_CP26") + " versionNeededToExtract [" + fh->versionNeededToExtract + "]"); } // get general purpose bit flag if (rc == kSTAFOk) { uLong iL; rc = util.getShort(zf, &iL); fh->generalPurposeBitFlag = (unsigned short)iL; STAFTrace::trace(kSTAFTraceServiceResult, STAFString("STAFZipCentralDir::readInData_CP27") + " generalPurposeBitFlag [" + fh->generalPurposeBitFlag + "]"); } // get compression method if (rc == kSTAFOk) { uLong iL; rc = util.getShort(zf, &iL); fh->compressionMethod = (unsigned short)iL; STAFTrace::trace(kSTAFTraceServiceResult, STAFString("STAFZipCentralDir::readInData_CP28") + " compressionMethod [" + fh->compressionMethod + "]"); } // get last mod time date if (rc == kSTAFOk) { rc = util.getLong(zf, &fh->lastModifiedTimeDate); STAFTrace::trace(kSTAFTraceServiceResult, STAFString("STAFZipCentralDir::readInData_CP29") + " lastModifiedTimeDate [" + fh->lastModifiedTimeDate + "]"); } // get CRC32 if (rc == kSTAFOk) { rc = util.getLong(zf, &fh->crc); STAFTrace::trace(kSTAFTraceServiceResult, STAFString("STAFZipCentralDir::readInData_CP30") + " crc [" + fh->crc + "]"); } // get compressed size if (rc == kSTAFOk) { rc = util.getLong(zf, &fh->compressedSize); STAFTrace::trace(kSTAFTraceServiceResult, STAFString("STAFZipCentralDir::readInData_CP31") + " compressedSize [" + fh->compressedSize + "]"); } // get uncompressed size if (rc == kSTAFOk) { rc = util.getLong(zf, &fh->uncompressedSize); STAFTrace::trace(kSTAFTraceServiceResult, STAFString("STAFZipCentralDir::readInData_CP32") + " uncompressedSize [" + fh->uncompressedSize + "]"); } // get file name length if (rc == kSTAFOk) { uLong iL; rc = util.getShort(zf, &iL); fh->fileNameLength = (unsigned short)iL; fh->size += fh->fileNameLength; STAFTrace::trace(kSTAFTraceServiceResult, STAFString("STAFZipCentralDir::readInData_CP33") + " fileNameLength [" + fh->fileNameLength + "] " + "size [" + fh->size + "]"); } // get extra field length if (rc == kSTAFOk) { uLong iL; rc = util.getShort(zf, &iL); fh->extraFieldLength = (unsigned short)iL; fh->size += fh->extraFieldLength; STAFTrace::trace(kSTAFTraceServiceResult, STAFString("STAFZipCentralDir::readInData_CP34") + " extraFieldLength [" + fh->extraFieldLength + "] " + "size [" + fh->size + "]"); } // get file comment length if (rc == kSTAFOk) { uLong iL; rc = util.getShort(zf, &iL); fh->fileCommentLength = (unsigned short)iL; fh->size += fh->fileCommentLength; STAFTrace::trace(kSTAFTraceServiceResult, STAFString("STAFZipCentralDir::readInData_CP35") + " fileCommentLength [" + fh->fileCommentLength + "] " + "size [" + fh->size + "]"); } // get disk number start if (rc == kSTAFOk) { uLong iL; rc = util.getShort(zf, &iL); fh->diskNumberStart = (unsigned short)iL; STAFTrace::trace(kSTAFTraceServiceResult, STAFString("STAFZipCentralDir::readInData_CP36") + " diskNumberStart [" + fh->diskNumberStart + "]"); } // get internal file attributes if (rc == kSTAFOk) { uLong iL; rc = util.getShort(zf, &iL); fh->internalFileAttributes = (unsigned short)iL; STAFTrace::trace(kSTAFTraceServiceResult, STAFString("STAFZipCentralDir::readInData_CP37") + " internalFileAttributes [" + fh->internalFileAttributes + "]"); } // get external file attributes if (rc == kSTAFOk) { rc = util.getLong(zf, &fh->externalFileAttributes); STAFTrace::trace(kSTAFTraceServiceResult, STAFString("STAFZipCentralDir::readInData_CP38") + " externalFileAttributes [" + fh->externalFileAttributes + "]"); } // get local header offset if (rc == kSTAFOk) { rc = util.getLong(zf, &fh->localFileHeaderOffset); STAFTrace::trace(kSTAFTraceServiceResult, STAFString("STAFZipCentralDir::readInData_CP39") + " localFileHeaderOffset [" + fh->localFileHeaderOffset + "]"); } // get file name if (rc == kSTAFOk && fh->fileNameLength > 0) { buf = (unsigned char*)calloc(fh->fileNameLength + 1, 1); if (buf == NULL) { *result = STAFString("STAFZipCentralDir::readInData: ") + "Error allocating memory for file name length [" + (fh->fileNameLength + 1) + "].\n"; return kZIPNotEnoughMemory; } if (fread(buf, (uInt)fh->fileNameLength, 1, zf) !=1 ) { *result = STAFString("STAFZipCentralDir::readInData: ") + "Error reading filename.\n"; rc = kZIPGeneralZipError; } fh->fileName = (char*)buf; STAFTrace::trace(kSTAFTraceServiceResult, STAFString("STAFZipCentralDir::readInData_CP42") + " fileName [" + fh->fileName + "]"); } // get extra field if (rc == kSTAFOk && fh->extraFieldLength > 0) { buf = (unsigned char*)calloc(fh->extraFieldLength, 1); if(buf == NULL) { *result = STAFString("STAFZipCentralDir::readInData: ") + "Error allocating memory for extra field length [" + fh->extraFieldLength + "].\n"; return kZIPNotEnoughMemory; } STAFTrace::trace(kSTAFTraceServiceResult, STAFString("STAFZipCentralDir::readInData_CP45") + " extraField offset [" + ftell(zf) + "]"); if (fread(buf, (uInt)fh->extraFieldLength, 1, zf) !=1 ) { *result = STAFString("STAFZipCentralDir::readInData: ") + "Error reading extra field.\n"; rc = kZIPGeneralZipError; } fh->extraField = (void*)buf; } // get file comment if (rc == kSTAFOk && fh->fileCommentLength > 0) { buf = (unsigned char*)calloc(fh->fileCommentLength + 1, 1); if(buf == NULL) { *result = STAFString("STAFZipCentralDir::readInData: ") + "Error allocating memory for file comment length [" + (fh->fileCommentLength + 1) + "].\n"; return kZIPNotEnoughMemory; } if (fread(buf, (uInt)fh->fileCommentLength, 1, zf) !=1 ) { *result = STAFString("STAFZipCentralDir::readInData: ") + "Error reading file comment.\n"; rc = kZIPGeneralZipError; } fh->fileComment = (char*)buf; STAFTrace::trace(kSTAFTraceServiceResult, STAFString("STAFZipCentralDir::readInData_CP48") + " fileComment [" + fh->fileComment + "]"); } if (rc != kSTAFOk) { if ((*result).length() != 0) { *result = STAFString("STAFZipCentralDir::readInData: ")
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -