ZIP_EXTERN void zip_file_error_clear(struct zip_file *zf) { if (zf) { _zip_error_clear(&zf->error); } }
ZIP_EXTERN void zip_file_error_clear(struct zip_file *zf) { if (zf == NULL) return; _zip_error_clear(&zf->error); }
ZIP_EXTERN void zip_error_clear(struct zip *za) { if (za == NULL) return; _zip_error_clear(&za->error); }
zip_int64_t _zip_name_locate(zip_t *za, const char *fname, zip_flags_t flags, zip_error_t *error) { int (*cmp)(const char *, const char *); const char *fn, *p; zip_uint64_t i; if (za == NULL) return -1; if (fname == NULL) { zip_error_set(error, ZIP_ER_INVAL, 0); return -1; } if (flags & (ZIP_FL_NOCASE | ZIP_FL_NODIR | ZIP_FL_ENC_CP437)) { /* can't use hash table */ cmp = (flags & ZIP_FL_NOCASE) ? strcasecmp : strcmp; for (i = 0; i < za->nentry; i++) { fn = _zip_get_name(za, i, flags, error); /* newly added (partially filled) entry or error */ if (fn == NULL) continue; if (flags & ZIP_FL_NODIR) { p = strrchr(fn, '/'); if (p) fn = p + 1; } if (cmp(fname, fn) == 0) { _zip_error_clear(error); return (zip_int64_t)i; } } zip_error_set(error, ZIP_ER_NOENT, 0); return -1; } else { return _zip_hash_lookup(za->names, (const zip_uint8_t *)fname, flags, error); } }
zip_int64_t _zip_name_locate(struct zip *za, const char *fname, zip_flags_t flags, struct zip_error *error) { int (*cmp)(const char *, const char *); const char *fn, *p; zip_uint64_t i; if (za == NULL) return -1; if (fname == NULL) { _zip_error_set(error, ZIP_ER_INVAL, 0); return -1; } cmp = (flags & ZIP_FL_NOCASE) ? strcasecmp : strcmp; for (i=0; i<za->nentry; i++) { fn = _zip_get_name(za, i, flags, error); /* newly added (partially filled) entry or error */ if (fn == NULL) continue; if (flags & ZIP_FL_NODIR) { p = strrchr(fn, '/'); if (p) fn = p+1; } if (cmp(fname, fn) == 0) { _zip_error_clear(error); return (zip_int64_t)i; } } _zip_error_set(error, ZIP_ER_NOENT, 0); return -1; }
ZIP_EXTERN int zip_source_open(zip_source_t *src) { if (src->source_closed) { return -1; } if (src->write_state == ZIP_SOURCE_WRITE_REMOVED) { zip_error_set(&src->error, ZIP_ER_DELETED, 0); return -1; } if (ZIP_SOURCE_IS_OPEN_READING(src)) { if ((zip_source_supports(src) & ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_SEEK)) == 0) { zip_error_set(&src->error, ZIP_ER_INUSE, 0); return -1; } } else { if (ZIP_SOURCE_IS_LAYERED(src)) { if (zip_source_open(src->src) < 0) { _zip_error_set_from_source(&src->error, src->src); return -1; } } if (_zip_source_call(src, NULL, 0, ZIP_SOURCE_OPEN) < 0) { if (ZIP_SOURCE_IS_LAYERED(src)) { zip_source_close(src->src); } return -1; } } src->eof = false; src->had_read_error = false; _zip_error_clear(&src->error); src->open_count++; return 0; }
zip_error_clear(struct zip *za) { _zip_error_clear(&za->error); }