(streamInfo, streamedContent, streamingEnded, offset, platform, encodeFileName)
| 756 | * @return {Object} the zip parts. |
| 757 | */ |
| 758 | var generateZipParts = function(streamInfo, streamedContent, streamingEnded, offset, platform, encodeFileName) { |
| 759 | var file = streamInfo['file'], |
| 760 | compression = streamInfo['compression'], |
| 761 | useCustomEncoding = encodeFileName !== utf8.utf8encode, |
| 762 | encodedFileName = utils.transformTo("string", encodeFileName(file.name)), |
| 763 | utfEncodedFileName = utils.transformTo("string", utf8.utf8encode(file.name)), |
| 764 | comment = file.comment, |
| 765 | encodedComment = utils.transformTo("string", encodeFileName(comment)), |
| 766 | utfEncodedComment = utils.transformTo("string", utf8.utf8encode(comment)), |
| 767 | useUTF8ForFileName = utfEncodedFileName.length !== file.name.length, |
| 768 | useUTF8ForComment = utfEncodedComment.length !== comment.length, |
| 769 | dosTime, |
| 770 | dosDate, |
| 771 | extraFields = "", |
| 772 | unicodePathExtraField = "", |
| 773 | unicodeCommentExtraField = "", |
| 774 | dir = file.dir, |
| 775 | date = file.date; |
| 776 | |
| 777 | |
| 778 | var dataInfo = { |
| 779 | crc32 : 0, |
| 780 | compressedSize : 0, |
| 781 | uncompressedSize : 0 |
| 782 | }; |
| 783 | |
| 784 | // if the content is streamed, the sizes/crc32 are only available AFTER |
| 785 | // the end of the stream. |
| 786 | if (!streamedContent || streamingEnded) { |
| 787 | dataInfo.crc32 = streamInfo['crc32']; |
| 788 | dataInfo.compressedSize = streamInfo['compressedSize']; |
| 789 | dataInfo.uncompressedSize = streamInfo['uncompressedSize']; |
| 790 | } |
| 791 | |
| 792 | var bitflag = 0; |
| 793 | if (streamedContent) { |
| 794 | // Bit 3: the sizes/crc32 are set to zero in the local header. |
| 795 | // The correct values are put in the data descriptor immediately |
| 796 | // following the compressed data. |
| 797 | bitflag |= 0x0008; |
| 798 | } |
| 799 | if (!useCustomEncoding && (useUTF8ForFileName || useUTF8ForComment)) { |
| 800 | // Bit 11: Language encoding flag (EFS). |
| 801 | bitflag |= 0x0800; |
| 802 | } |
| 803 | |
| 804 | |
| 805 | var extFileAttr = 0; |
| 806 | var versionMadeBy = 0; |
| 807 | if (dir) { |
| 808 | // dos or unix, we set the dos dir flag |
| 809 | extFileAttr |= 0x00010; |
| 810 | } |
| 811 | if(platform === "UNIX") { |
| 812 | versionMadeBy = 0x031E; // UNIX, version 3.0 |
| 813 | extFileAttr |= generateUnixExternalFileAttr(file.unixPermissions, dir); |
| 814 | } else { // DOS or other, fallback to DOS |
| 815 | versionMadeBy = 0x0014; // DOS, version 2.0 |
no test coverage detected