| 1880 | } |
| 1881 | |
| 1882 | extern int ZEXPORT zipClose (zipFile file, const char* global_comment) |
| 1883 | { |
| 1884 | zip64_internal* zi; |
| 1885 | int err = 0; |
| 1886 | uLong size_centraldir = 0; |
| 1887 | ZPOS64_T centraldir_pos_inzip; |
| 1888 | ZPOS64_T pos; |
| 1889 | |
| 1890 | if (file == NULL) |
| 1891 | return ZIP_PARAMERROR; |
| 1892 | |
| 1893 | zi = (zip64_internal*)file; |
| 1894 | |
| 1895 | if (zi->in_opened_file_inzip == 1) |
| 1896 | { |
| 1897 | err = zipCloseFileInZip (file); |
| 1898 | } |
| 1899 | |
| 1900 | #ifndef NO_ADDFILEINEXISTINGZIP |
| 1901 | if (global_comment==NULL) |
| 1902 | global_comment = zi->globalcomment; |
| 1903 | #endif |
| 1904 | |
| 1905 | centraldir_pos_inzip = ZTELL64(zi->z_filefunc,zi->filestream); |
| 1906 | |
| 1907 | if (err==ZIP_OK) |
| 1908 | { |
| 1909 | linkedlist_datablock_internal* ldi = zi->central_dir.first_block; |
| 1910 | while (ldi!=NULL) |
| 1911 | { |
| 1912 | if ((err==ZIP_OK) && (ldi->filled_in_this_block>0)) |
| 1913 | { |
| 1914 | if (ZWRITE64(zi->z_filefunc,zi->filestream, ldi->data, ldi->filled_in_this_block) != ldi->filled_in_this_block) |
| 1915 | err = ZIP_ERRNO; |
| 1916 | } |
| 1917 | |
| 1918 | size_centraldir += ldi->filled_in_this_block; |
| 1919 | ldi = ldi->next_datablock; |
| 1920 | } |
| 1921 | } |
| 1922 | free_linkedlist(&(zi->central_dir)); |
| 1923 | |
| 1924 | pos = centraldir_pos_inzip - zi->add_position_when_writing_offset; |
| 1925 | if(pos >= 0xffffffff || zi->number_entry > 0xFFFF) |
| 1926 | { |
| 1927 | ZPOS64_T Zip64EOCDpos = ZTELL64(zi->z_filefunc,zi->filestream); |
| 1928 | Write_Zip64EndOfCentralDirectoryRecord(zi, size_centraldir, centraldir_pos_inzip); |
| 1929 | |
| 1930 | Write_Zip64EndOfCentralDirectoryLocator(zi, Zip64EOCDpos); |
| 1931 | } |
| 1932 | |
| 1933 | if (err==ZIP_OK) |
| 1934 | err = Write_EndOfCentralDirectoryRecord(zi, size_centraldir, centraldir_pos_inzip); |
| 1935 | |
| 1936 | if(err == ZIP_OK) |
| 1937 | err = Write_GlobalComment(zi, global_comment); |
| 1938 | |
| 1939 | if (ZCLOSE64(zi->z_filefunc,zi->filestream) != 0) |
no test coverage detected