MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / zipClose

Function zipClose

lib/QuaZip/quazip/zip.c:1948–2023  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1946}
1947
1948extern int ZEXPORT zipClose (zipFile file, const char* global_comment)
1949{
1950 zip64_internal* zi;
1951 int err = 0;
1952 uLong size_centraldir = 0;
1953 ZPOS64_T centraldir_pos_inzip;
1954 ZPOS64_T pos;
1955
1956 if (file == NULL)
1957 return ZIP_PARAMERROR;
1958
1959 zi = (zip64_internal*)file;
1960
1961 if (zi->in_opened_file_inzip == 1)
1962 {
1963 err = zipCloseFileInZip (file);
1964 }
1965
1966#ifndef NO_ADDFILEINEXISTINGZIP
1967 if (global_comment==NULL)
1968 global_comment = zi->globalcomment;
1969#endif
1970
1971 centraldir_pos_inzip = ZTELL64(zi->z_filefunc,zi->filestream);
1972
1973 if (err==ZIP_OK)
1974 {
1975 linkedlist_datablock_internal* ldi = zi->central_dir.first_block;
1976 while (ldi!=NULL)
1977 {
1978 if ((err==ZIP_OK) && (ldi->filled_in_this_block>0))
1979 {
1980 if (ZWRITE64(zi->z_filefunc,zi->filestream, ldi->data, ldi->filled_in_this_block) != ldi->filled_in_this_block)
1981 err = ZIP_ERRNO;
1982 }
1983
1984 size_centraldir += ldi->filled_in_this_block;
1985 ldi = ldi->next_datablock;
1986 }
1987 }
1988 free_linkedlist(&(zi->central_dir));
1989
1990 pos = centraldir_pos_inzip - zi->add_position_when_writting_offset;
1991 if(pos >= 0xffffffff || zi->number_entry > 0xFFFF)
1992 {
1993 ZPOS64_T Zip64EOCDpos = ZTELL64(zi->z_filefunc,zi->filestream);
1994 Write_Zip64EndOfCentralDirectoryRecord(zi, size_centraldir, centraldir_pos_inzip);
1995
1996 Write_Zip64EndOfCentralDirectoryLocator(zi, Zip64EOCDpos);
1997 }
1998
1999 if (err==ZIP_OK)
2000 err = Write_EndOfCentralDirectoryRecord(zi, size_centraldir, centraldir_pos_inzip);
2001
2002 if(err == ZIP_OK)
2003 err = Write_GlobalComment(zi, global_comment);
2004
2005 if ((zi->flags & ZIP_AUTO_CLOSE) != 0) {

Callers 2

openMethod · 0.85
closeMethod · 0.85

Tested by

no test coverage detected