diff options
Diffstat (limited to 'ext/zip/lib/zip_source_stat.c')
-rw-r--r-- | ext/zip/lib/zip_source_stat.c | 39 |
1 files changed, 15 insertions, 24 deletions
diff --git a/ext/zip/lib/zip_source_stat.c b/ext/zip/lib/zip_source_stat.c index 732db4f55f..34cb05f452 100644 --- a/ext/zip/lib/zip_source_stat.c +++ b/ext/zip/lib/zip_source_stat.c @@ -1,6 +1,6 @@ /* zip_source_stat.c -- get meta information from zip_source - Copyright (C) 2009 Dieter Baron and Thomas Klausner + Copyright (C) 2009-2014 Dieter Baron and Thomas Klausner This file is part of libzip, a library to manipulate ZIP archives. The authors can be contacted at <libzip@nih.at> @@ -17,7 +17,7 @@ 3. The names of the authors may not be used to endorse or promote products derived from this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -32,39 +32,30 @@ */ - #include "zipint.h" - int -zip_source_stat(struct zip_source *src, struct zip_stat *st) +zip_source_stat(zip_source_t *src, zip_stat_t *st) { - zip_int64_t ret; - + if (src->source_closed) { + return -1; + } if (st == NULL) { - src->error_source = ZIP_LES_INVAL; + zip_error_set(&src->error, ZIP_ER_INVAL, 0); return -1; } - if (src->src == NULL) { - if (src->cb.f(src->ud, st, sizeof(*st), ZIP_SOURCE_STAT) < 0) - return -1; - return 0; + zip_stat_init(st); + + if (ZIP_SOURCE_IS_LAYERED(src)) { + if (zip_source_stat(src->src, st) < 0) { + _zip_error_set_from_source(&src->error, src->src); + return -1; + } } - if (zip_source_stat(src->src, st) < 0) { - src->error_source = ZIP_LES_LOWER; - return -1; - } - - ret = src->cb.l(src->src, src->ud, st, sizeof(*st), ZIP_SOURCE_STAT); - - if (ret < 0) { - if (ret == ZIP_SOURCE_ERR_LOWER) - src->error_source = ZIP_LES_LOWER; - else - src->error_source = ZIP_LES_UPPER; + if (_zip_source_call(src, st, sizeof(*st), ZIP_SOURCE_STAT) < 0) { return -1; } |