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

Method copyFpToFp

tools/aapt/ZipFile.cpp:711–734  ·  view source on GitHub ↗

* Copy all of the bytes in "src" to "dst". * * On exit, "srcFp" will be seeked to the end of the file, and "dstFp" * will be seeked immediately past the data. */

Source from the content-addressed store, hash-verified

709 * will be seeked immediately past the data.
710 */
711status_t ZipFile::copyFpToFp(FILE* dstFp, FILE* srcFp, unsigned long* pCRC32)
712{
713 unsigned char tmpBuf[32768];
714 size_t count;
715
716 *pCRC32 = crc32(0L, Z_NULL, 0);
717
718 while (1) {
719 count = fread(tmpBuf, 1, sizeof(tmpBuf), srcFp);
720 if (ferror(srcFp) || ferror(dstFp))
721 return errnoToStatus(errno);
722 if (count == 0)
723 break;
724
725 *pCRC32 = crc32(*pCRC32, tmpBuf, count);
726
727 if (fwrite(tmpBuf, 1, count, dstFp) != count) {
728 ALOGD("fwrite %d bytes failed\n", (int) count);
729 return UNKNOWN_ERROR;
730 }
731 }
732
733 return NO_ERROR;
734}
735
736/*
737 * Copy all of the bytes in "src" to "dst".

Callers

nothing calls this directly

Calls 1

errnoToStatusFunction · 0.85

Tested by

no test coverage detected