MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / zipClose

Function zipClose

extlibs/minizip/src/zip.c:1868–1935  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1866}
1867
1868extern int ZEXPORT zipClose(zipFile file, const char* global_comment)
1869{
1870 zip64_internal* zi;
1871 int err = 0;
1872 uLong size_centraldir = 0;
1873 ZPOS64_T centraldir_pos_inzip;
1874 ZPOS64_T pos;
1875
1876 if (file == NULL)
1877 return ZIP_PARAMERROR;
1878
1879 zi = (zip64_internal*)file;
1880
1881 if (zi->in_opened_file_inzip == 1)
1882 {
1883 err = zipCloseFileInZip(file);
1884 }
1885
1886#ifndef NO_ADDFILEINEXISTINGZIP
1887 if (global_comment == NULL)
1888 global_comment = zi->globalcomment;
1889#endif
1890
1891 centraldir_pos_inzip = ZTELL64(zi->z_filefunc,zi->filestream);
1892
1893 if (err == ZIP_OK)
1894 {
1895 linkedlist_datablock_internal* ldi = zi->central_dir.first_block;
1896 while (ldi != NULL)
1897 {
1898 if ((err == ZIP_OK) && (ldi->filled_in_this_block > 0))
1899 {
1900 if (ZWRITE64(zi->z_filefunc,zi->filestream, ldi->data, ldi->filled_in_this_block) != ldi->filled_in_this_block)
1901 err = ZIP_ERRNO;
1902 }
1903
1904 size_centraldir += ldi->filled_in_this_block;
1905 ldi = ldi->next_datablock;
1906 }
1907 }
1908 free_linkedlist(&(zi->central_dir));
1909
1910 pos = centraldir_pos_inzip - zi->add_position_when_writing_offset;
1911 if (pos >= 0xffffffff || zi->number_entry > 0xFFFF)
1912 {
1913 ZPOS64_T Zip64EOCDpos = ZTELL64(zi->z_filefunc,zi->filestream);
1914 Write_Zip64EndOfCentralDirectoryRecord(zi, size_centraldir, centraldir_pos_inzip);
1915
1916 Write_Zip64EndOfCentralDirectoryLocator(zi, Zip64EOCDpos);
1917 }
1918
1919 if (err == ZIP_OK)
1920 err = Write_EndOfCentralDirectoryRecord(zi, size_centraldir, centraldir_pos_inzip);
1921
1922 if (err == ZIP_OK)
1923 err = Write_GlobalComment(zi, global_comment);
1924
1925 if (ZCLOSE64(zi->z_filefunc,zi->filestream) != 0)

Callers 1

closeMethod · 0.85

Tested by

no test coverage detected