| 1800 | } |
| 1801 | |
| 1802 | int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) |
| 1803 | { |
| 1804 | int err = ZIP_OK; |
| 1805 | |
| 1806 | /*signature*/ |
| 1807 | err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (uLong)ENDHEADERMAGIC, 4); |
| 1808 | |
| 1809 | if (err == ZIP_OK) /* number of this disk */ |
| 1810 | err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (uLong)0, 2); |
| 1811 | |
| 1812 | if (err == ZIP_OK) /* number of the disk with the start of the central directory */ |
| 1813 | err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (uLong)0, 2); |
| 1814 | |
| 1815 | if (err == ZIP_OK) /* total number of entries in the central dir on this disk */ |
| 1816 | { |
| 1817 | { |
| 1818 | if (zi->number_entry >= 0xFFFF) |
| 1819 | err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (uLong)0xffff, 2); // use value in ZIP64 record |
| 1820 | else |
| 1821 | err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (uLong)zi->number_entry, 2); |
| 1822 | } |
| 1823 | } |
| 1824 | |
| 1825 | if (err == ZIP_OK) /* total number of entries in the central dir */ |
| 1826 | { |
| 1827 | if (zi->number_entry >= 0xFFFF) |
| 1828 | err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (uLong)0xffff, 2); // use value in ZIP64 record |
| 1829 | else |
| 1830 | err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (uLong)zi->number_entry, 2); |
| 1831 | } |
| 1832 | |
| 1833 | if (err == ZIP_OK) /* size of the central directory */ |
| 1834 | err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (uLong)size_centraldir, 4); |
| 1835 | |
| 1836 | if (err == ZIP_OK) /* offset of start of central directory with respect to the starting disk number */ |
| 1837 | { |
| 1838 | ZPOS64_T pos = centraldir_pos_inzip - zi->add_position_when_writing_offset; |
| 1839 | if (pos >= 0xffffffff) |
| 1840 | { |
| 1841 | err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (uLong)0xffffffff, 4); |
| 1842 | } |
| 1843 | else |
| 1844 | err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (uLong)(centraldir_pos_inzip - zi->add_position_when_writing_offset), 4); |
| 1845 | } |
| 1846 | |
| 1847 | return err; |
| 1848 | } |
| 1849 | |
| 1850 | int Write_GlobalComment(zip64_internal* zi, const char* global_comment) |
| 1851 | { |
no test coverage detected