Lines Matching refs:za
71 zip_close(struct zip *za) in zip_close() argument
88 if (za == NULL) in zip_close()
91 if (!_zip_changed(za, &survivors)) { in zip_close()
92 _zip_free(za); in zip_close()
98 if (za->zn && za->zp) { in zip_close()
99 if (remove(za->zn) != 0) { in zip_close()
100 _zip_error_set(&za->error, ZIP_ER_REMOVE, errno); in zip_close()
104 _zip_free(za); in zip_close()
112 if ((cd=_zip_cdir_new(survivors, &za->error)) == NULL) { in zip_close()
121 if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0)) { in zip_close()
124 &za->error); in zip_close()
132 else if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, ZIP_FL_UNCHANGED) == 0) { in zip_close()
133 if (_zip_cdir_set_comment(cd, za) == -1) { in zip_close()
140 if ((temp=_zip_create_temp_output(za, &out)) == NULL) { in zip_close()
148 for (i=j=0; i<za->nentry; i++) { in zip_close()
149 if (za->entry[i].state == ZIP_ST_DELETED) in zip_close()
153 filelist[j].name = zip_get_name(za, i, 0); in zip_close()
156 if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0)) in zip_close()
160 new_torrentzip = (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0) == 1 in zip_close()
161 && zip_get_archive_flag(za, ZIP_AFL_TORRENT, in zip_close()
170 if (ZIP_ENTRY_DATA_CHANGED(za->entry+i) || new_torrentzip) { in zip_close()
172 if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0)) in zip_close()
179 if (za->entry[i].ch_filename == NULL) { in zip_close()
180 if (za->entry[i].state == ZIP_ST_ADDED) { in zip_close()
187 de.filename = strdup(za->cdir->entry[i].filename); in zip_close()
189 cd->entry[j].filename = za->cdir->entry[i].filename; in zip_close()
196 if ((NULL == za->zp) || (fseeko(za->zp, za->cdir->entry[i].offset, SEEK_SET) != 0)) { in zip_close()
197 _zip_error_set(&za->error, ZIP_ER_SEEK, errno); in zip_close()
201 if (_zip_dirent_read(&de, za->zp, NULL, NULL, 1, in zip_close()
202 &za->error) != 0) { in zip_close()
206 memcpy(cd->entry+j, za->cdir->entry+i, sizeof(cd->entry[j])); in zip_close()
208 de.crc = za->cdir->entry[i].crc; in zip_close()
209 de.comp_size = za->cdir->entry[i].comp_size; in zip_close()
210 de.uncomp_size = za->cdir->entry[i].uncomp_size; in zip_close()
216 if (za->entry[i].ch_filename) { in zip_close()
218 if ((de.filename=strdup(za->entry[i].ch_filename)) == NULL) { in zip_close()
223 cd->entry[j].filename = za->entry[i].ch_filename; in zip_close()
227 if (za->entry[i].ch_extra_len != -1) { in zip_close()
229 if ((de.extrafield=malloc(za->entry[i].ch_extra_len)) == NULL) { in zip_close()
233 memcpy(de.extrafield, za->entry[i].ch_extra, za->entry[i].ch_extra_len); in zip_close()
234 de.extrafield_len = za->entry[i].ch_extra_len; in zip_close()
243 if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0) == 0 in zip_close()
244 && za->entry[i].ch_comment_len != -1) { in zip_close()
246 cd->entry[j].comment = za->entry[i].ch_comment; in zip_close()
247 cd->entry[j].comment_len = za->entry[i].ch_comment_len; in zip_close()
252 if (ZIP_ENTRY_DATA_CHANGED(za->entry+i) || new_torrentzip) { in zip_close()
256 if (!ZIP_ENTRY_DATA_CHANGED(za->entry+i)) { in zip_close()
257 if ((zs=zip_source_zip(za, za, i, ZIP_FL_RECOMPRESS, 0, -1)) in zip_close()
264 if (add_data(za, zs ? zs : za->entry[i].source, &de, out) < 0) { in zip_close()
280 if (_zip_dirent_write(&de, out, 1, &za->error) < 0) { in zip_close()
285 if (copy_data(za->zp, cd->entry[j].comp_size, out, in zip_close()
286 &za->error) < 0) { in zip_close()
298 if (write_cdir(za, cd, out) < 0) in zip_close()
315 _zip_error_set(&za->error, ZIP_ER_CLOSE, errno); in zip_close()
321 if (za->zp) { in zip_close()
322 fclose(za->zp); in zip_close()
323 za->zp = NULL; in zip_close()
326 if (_zip_rename(temp, za->zn) != 0) { in zip_close()
327 _zip_error_set(&za->error, ZIP_ER_RENAME, errno); in zip_close()
332 za->zp = fopen(za->zn, "rb"); in zip_close()
339 chmod(za->zn, 0666&~mask); in zip_close()
342 _zip_free(za); in zip_close()
351 add_data(struct zip *za, struct zip_source *src, struct zip_dirent *de, in add_data() argument
361 _zip_error_set_from_source(&za->error, src); in add_data()
367 if (_zip_dirent_write(de, ft, 1, &za->error) < 0) in add_data()
370 if ((s2=zip_source_crc(za, src, 0)) == NULL) { in add_data()
382 _zip_error_set(&za->error, ZIP_ER_COMPNOTSUPP, 0); in add_data()
386 if ((s2=comp_impl(za, s2, ZIP_CM_DEFLATE, ZIP_CODEC_ENCODE)) in add_data()
398 ret = copy_source(za, s2, ft); in add_data()
417 _zip_error_set(&za->error, ZIP_ER_SEEK, errno); in add_data()
427 if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0)) in add_data()
430 if (_zip_dirent_write(de, ft, 1, &za->error) < 0) in add_data()
434 _zip_error_set(&za->error, ZIP_ER_SEEK, errno); in add_data()
477 copy_source(struct zip *za, struct zip_source *src, FILE *ft) in copy_source() argument
484 _zip_error_set_from_source(&za->error, src); in copy_source()
491 _zip_error_set(&za->error, ZIP_ER_WRITE, errno); in copy_source()
499 _zip_error_set_from_source(&za->error, src); in copy_source()
511 write_cdir(struct zip *za, struct zip_cdir *cd, FILE *out) in write_cdir() argument
517 if (_zip_cdir_write(cd, out, &za->error) < 0) in write_cdir()
520 if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0) == 0) in write_cdir()
528 if (_zip_filerange_crc(out, cd->offset, cd->size, &crc, &za->error) < 0) in write_cdir()
534 _zip_error_set(&za->error, ZIP_ER_SEEK, errno); in write_cdir()
539 _zip_error_set(&za->error, ZIP_ER_WRITE, errno); in write_cdir()
573 _zip_changed(struct zip *za, int *survivorsp) in _zip_changed() argument
579 if (za->ch_comment_len != -1 in _zip_changed()
580 || za->ch_flags != za->flags) in _zip_changed()
583 for (i=0; i<za->nentry; i++) { in _zip_changed()
584 if ((za->entry[i].state != ZIP_ST_UNCHANGED) in _zip_changed()
585 || (za->entry[i].ch_extra_len != -1) in _zip_changed()
586 || (za->entry[i].ch_comment_len != -1)) in _zip_changed()
588 if (za->entry[i].state != ZIP_ST_DELETED) in _zip_changed()
601 _zip_create_temp_output(struct zip *za, FILE **outp) in _zip_create_temp_output() argument
606 int len = strlen(za->zn) + 8; in _zip_create_temp_output()
609 _zip_error_set(&za->error, ZIP_ER_MEMORY, 0); in _zip_create_temp_output()
613 snprintf(temp, len, "%s.XXXXXX", za->zn); in _zip_create_temp_output()
616 _zip_error_set(&za->error, ZIP_ER_TMPOPEN, errno); in _zip_create_temp_output()
622 _zip_error_set(&za->error, ZIP_ER_TMPOPEN, errno); in _zip_create_temp_output()