mz_stream_is_open:
   27|  5.10k|int32_t mz_stream_is_open(void *stream) {
   28|  5.10k|    mz_stream *strm = (mz_stream *)stream;
   29|  5.10k|    if (!strm || !strm->vtbl || !strm->vtbl->is_open)
  ------------------
  |  Branch (29:9): [True: 0, False: 5.10k]
  |  Branch (29:18): [True: 0, False: 5.10k]
  |  Branch (29:33): [True: 0, False: 5.10k]
  ------------------
   30|      0|        return MZ_STREAM_ERROR;
  ------------------
  |  |   22|      0|#define MZ_STREAM_ERROR                 (-1) /* zlib */
  ------------------
   31|  5.10k|    return strm->vtbl->is_open(strm);
   32|  5.10k|}
mz_stream_read:
   34|  1.23k|int32_t mz_stream_read(void *stream, void *buf, int32_t size) {
   35|  1.23k|    mz_stream *strm = (mz_stream *)stream;
   36|  1.23k|    if (!strm || !strm->vtbl || !strm->vtbl->read)
  ------------------
  |  Branch (36:9): [True: 0, False: 1.23k]
  |  Branch (36:18): [True: 0, False: 1.23k]
  |  Branch (36:33): [True: 0, False: 1.23k]
  ------------------
   37|      0|        return MZ_PARAM_ERROR;
  ------------------
  |  |   31|      0|#define MZ_PARAM_ERROR                  (-102)
  ------------------
   38|  1.23k|    if (mz_stream_is_open(stream) != MZ_OK)
  ------------------
  |  |   21|  1.23k|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (38:9): [True: 0, False: 1.23k]
  ------------------
   39|      0|        return MZ_STREAM_ERROR;
  ------------------
  |  |   22|      0|#define MZ_STREAM_ERROR                 (-1) /* zlib */
  ------------------
   40|  1.23k|    return strm->vtbl->read(strm, buf, size);
   41|  1.23k|}
mz_stream_read_uint8:
   60|    972|int32_t mz_stream_read_uint8(void *stream, uint8_t *value) {
   61|    972|    int32_t err = MZ_OK;
  ------------------
  |  |   21|    972|#define MZ_OK                           (0)  /* zlib */
  ------------------
   62|    972|    uint64_t value64 = 0;
   63|       |
   64|    972|    *value = 0;
   65|    972|    err = mz_stream_read_value(stream, &value64, sizeof(uint8_t));
   66|    972|    if (err == MZ_OK)
  ------------------
  |  |   21|    972|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (66:9): [True: 784, False: 188]
  ------------------
   67|    784|        *value = (uint8_t)value64;
   68|    972|    return err;
   69|    972|}
mz_stream_read_uint16:
   71|    264|int32_t mz_stream_read_uint16(void *stream, uint16_t *value) {
   72|    264|    int32_t err = MZ_OK;
  ------------------
  |  |   21|    264|#define MZ_OK                           (0)  /* zlib */
  ------------------
   73|    264|    uint64_t value64 = 0;
   74|       |
   75|    264|    *value = 0;
   76|    264|    err = mz_stream_read_value(stream, &value64, sizeof(uint16_t));
   77|    264|    if (err == MZ_OK)
  ------------------
  |  |   21|    264|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (77:9): [True: 242, False: 22]
  ------------------
   78|    242|        *value = (uint16_t)value64;
   79|    264|    return err;
   80|    264|}
mz_stream_write:
  101|  1.55k|int32_t mz_stream_write(void *stream, const void *buf, int32_t size) {
  102|  1.55k|    mz_stream *strm = (mz_stream *)stream;
  103|  1.55k|    if (size == 0)
  ------------------
  |  Branch (103:9): [True: 0, False: 1.55k]
  ------------------
  104|      0|        return size;
  105|  1.55k|    if (!strm || !strm->vtbl || !strm->vtbl->write)
  ------------------
  |  Branch (105:9): [True: 0, False: 1.55k]
  |  Branch (105:18): [True: 0, False: 1.55k]
  |  Branch (105:33): [True: 0, False: 1.55k]
  ------------------
  106|      0|        return MZ_PARAM_ERROR;
  ------------------
  |  |   31|      0|#define MZ_PARAM_ERROR                  (-102)
  ------------------
  107|  1.55k|    if (mz_stream_is_open(stream) != MZ_OK)
  ------------------
  |  |   21|  1.55k|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (107:9): [True: 295, False: 1.26k]
  ------------------
  108|    295|        return MZ_STREAM_ERROR;
  ------------------
  |  |   22|    295|#define MZ_STREAM_ERROR                 (-1) /* zlib */
  ------------------
  109|  1.26k|    return strm->vtbl->write(strm, buf, size);
  110|  1.55k|}
mz_stream_write_uint8:
  133|    840|int32_t mz_stream_write_uint8(void *stream, uint8_t value) {
  134|    840|    return mz_stream_write_value(stream, value, sizeof(uint8_t));
  135|    840|}
mz_stream_write_uint32:
  141|    295|int32_t mz_stream_write_uint32(void *stream, uint32_t value) {
  142|    295|    return mz_stream_write_value(stream, value, sizeof(uint32_t));
  143|    295|}
mz_stream_copy:
  153|    210|int32_t mz_stream_copy(void *target, void *source, int32_t len) {
  154|    210|    return mz_stream_copy_stream(target, NULL, source, NULL, len);
  155|    210|}
mz_stream_copy_stream:
  162|    210|    mz_stream_read_cb read_cb, int32_t len) {
  163|    210|    uint8_t buf[16384];
  164|    210|    int32_t bytes_to_copy = 0;
  165|    210|    int32_t read = 0;
  166|    210|    int32_t written = 0;
  167|       |
  168|    210|    if (!write_cb)
  ------------------
  |  Branch (168:9): [True: 210, False: 0]
  ------------------
  169|    210|        write_cb = mz_stream_write;
  170|    210|    if (!read_cb)
  ------------------
  |  Branch (170:9): [True: 210, False: 0]
  ------------------
  171|    210|        read_cb = mz_stream_read;
  172|       |
  173|    210|    while (len > 0) {
  ------------------
  |  Branch (173:12): [True: 0, False: 210]
  ------------------
  174|      0|        bytes_to_copy = len;
  175|      0|        if (bytes_to_copy > (int32_t)sizeof(buf))
  ------------------
  |  Branch (175:13): [True: 0, False: 0]
  ------------------
  176|      0|            bytes_to_copy = sizeof(buf);
  177|      0|        read = read_cb(source, buf, bytes_to_copy);
  178|      0|        if (read <= 0)
  ------------------
  |  Branch (178:13): [True: 0, False: 0]
  ------------------
  179|      0|            return MZ_STREAM_ERROR;
  ------------------
  |  |   22|      0|#define MZ_STREAM_ERROR                 (-1) /* zlib */
  ------------------
  180|      0|        written = write_cb(target, buf, read);
  181|      0|        if (written != read)
  ------------------
  |  Branch (181:13): [True: 0, False: 0]
  ------------------
  182|      0|            return MZ_STREAM_ERROR;
  ------------------
  |  |   22|      0|#define MZ_STREAM_ERROR                 (-1) /* zlib */
  ------------------
  183|      0|        len -= read;
  184|      0|    }
  185|       |
  186|    210|    return MZ_OK;
  ------------------
  |  |   21|    210|#define MZ_OK                           (0)  /* zlib */
  ------------------
  187|    210|}
mz_stream_tell:
  214|  1.47k|int64_t mz_stream_tell(void *stream) {
  215|  1.47k|    mz_stream *strm = (mz_stream *)stream;
  216|  1.47k|    if (!strm || !strm->vtbl || !strm->vtbl->tell)
  ------------------
  |  Branch (216:9): [True: 0, False: 1.47k]
  |  Branch (216:18): [True: 0, False: 1.47k]
  |  Branch (216:33): [True: 0, False: 1.47k]
  ------------------
  217|      0|        return MZ_PARAM_ERROR;
  ------------------
  |  |   31|      0|#define MZ_PARAM_ERROR                  (-102)
  ------------------
  218|  1.47k|    if (mz_stream_is_open(stream) != MZ_OK)
  ------------------
  |  |   21|  1.47k|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (218:9): [True: 420, False: 1.05k]
  ------------------
  219|    420|        return MZ_STREAM_ERROR;
  ------------------
  |  |   22|    420|#define MZ_STREAM_ERROR                 (-1) /* zlib */
  ------------------
  220|  1.05k|    return strm->vtbl->tell(strm);
  221|  1.47k|}
mz_stream_seek:
  223|    630|int32_t mz_stream_seek(void *stream, int64_t offset, int32_t origin) {
  224|    630|    mz_stream *strm = (mz_stream *)stream;
  225|    630|    if (!strm || !strm->vtbl || !strm->vtbl->seek)
  ------------------
  |  Branch (225:9): [True: 0, False: 630]
  |  Branch (225:18): [True: 0, False: 630]
  |  Branch (225:33): [True: 0, False: 630]
  ------------------
  226|      0|        return MZ_PARAM_ERROR;
  ------------------
  |  |   31|      0|#define MZ_PARAM_ERROR                  (-102)
  ------------------
  227|    630|    if (mz_stream_is_open(stream) != MZ_OK)
  ------------------
  |  |   21|    630|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (227:9): [True: 0, False: 630]
  ------------------
  228|      0|        return MZ_STREAM_ERROR;
  ------------------
  |  |   22|      0|#define MZ_STREAM_ERROR                 (-1) /* zlib */
  ------------------
  229|    630|    if (origin == MZ_SEEK_SET && offset < 0)
  ------------------
  |  |   58|  1.26k|#define MZ_SEEK_SET                     (0)
  ------------------
  |  Branch (229:9): [True: 420, False: 210]
  |  Branch (229:34): [True: 0, False: 420]
  ------------------
  230|      0|        return MZ_SEEK_ERROR;
  ------------------
  |  |   42|      0|#define MZ_SEEK_ERROR                   (-113)
  ------------------
  231|    630|    return strm->vtbl->seek(strm, offset, origin);
  232|    630|}
mz_stream_close:
  357|    210|int32_t mz_stream_close(void *stream) {
  358|    210|    mz_stream *strm = (mz_stream *)stream;
  359|    210|    if (!strm || !strm->vtbl || !strm->vtbl->close)
  ------------------
  |  Branch (359:9): [True: 0, False: 210]
  |  Branch (359:18): [True: 0, False: 210]
  |  Branch (359:33): [True: 0, False: 210]
  ------------------
  360|      0|        return MZ_PARAM_ERROR;
  ------------------
  |  |   31|      0|#define MZ_PARAM_ERROR                  (-102)
  ------------------
  361|    210|    if (mz_stream_is_open(stream) != MZ_OK)
  ------------------
  |  |   21|    210|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (361:9): [True: 0, False: 210]
  ------------------
  362|      0|        return MZ_STREAM_ERROR;
  ------------------
  |  |   22|      0|#define MZ_STREAM_ERROR                 (-1) /* zlib */
  ------------------
  363|    210|    return strm->vtbl->close(strm);
  364|    210|}
mz_stream_error:
  366|    210|int32_t mz_stream_error(void *stream) {
  367|    210|    mz_stream *strm = (mz_stream *)stream;
  368|    210|    if (!strm || !strm->vtbl || !strm->vtbl->error)
  ------------------
  |  Branch (368:9): [True: 0, False: 210]
  |  Branch (368:18): [True: 0, False: 210]
  |  Branch (368:33): [True: 0, False: 210]
  ------------------
  369|      0|        return MZ_PARAM_ERROR;
  ------------------
  |  |   31|      0|#define MZ_PARAM_ERROR                  (-102)
  ------------------
  370|    210|    return strm->vtbl->error(strm);
  371|    210|}
mz_stream_get_prop_int64:
  386|    630|int32_t mz_stream_get_prop_int64(void *stream, int32_t prop, int64_t *value) {
  387|    630|    mz_stream *strm = (mz_stream *)stream;
  388|    630|    if (!strm || !strm->vtbl || !strm->vtbl->get_prop_int64)
  ------------------
  |  Branch (388:9): [True: 0, False: 630]
  |  Branch (388:18): [True: 0, False: 630]
  |  Branch (388:33): [True: 630, False: 0]
  ------------------
  389|    630|        return MZ_PARAM_ERROR;
  ------------------
  |  |   31|    630|#define MZ_PARAM_ERROR                  (-102)
  ------------------
  390|      0|    return strm->vtbl->get_prop_int64(stream, prop, value);
  391|    630|}
mz_stream_set_prop_int64:
  393|    210|int32_t mz_stream_set_prop_int64(void *stream, int32_t prop, int64_t value) {
  394|    210|    mz_stream *strm = (mz_stream *)stream;
  395|    210|    if (!strm || !strm->vtbl || !strm->vtbl->set_prop_int64)
  ------------------
  |  Branch (395:9): [True: 0, False: 210]
  |  Branch (395:18): [True: 0, False: 210]
  |  Branch (395:33): [True: 210, False: 0]
  ------------------
  396|    210|        return MZ_PARAM_ERROR;
  ------------------
  |  |   31|    210|#define MZ_PARAM_ERROR                  (-102)
  ------------------
  397|      0|    return strm->vtbl->set_prop_int64(stream, prop, value);
  398|    210|}
mz_stream_delete:
  406|    210|void mz_stream_delete(void **stream) {
  407|    210|    mz_stream *strm = NULL;
  408|    210|    if (!stream)
  ------------------
  |  Branch (408:9): [True: 0, False: 210]
  ------------------
  409|      0|        return;
  410|    210|    strm = (mz_stream *)*stream;
  411|    210|    if (strm && strm->vtbl && strm->vtbl->destroy)
  ------------------
  |  Branch (411:9): [True: 210, False: 0]
  |  Branch (411:17): [True: 210, False: 0]
  |  Branch (411:31): [True: 210, False: 0]
  ------------------
  412|    210|        strm->vtbl->destroy(stream);
  413|    210|    *stream = NULL;
  414|    210|}
mz_strm.c:mz_stream_read_value:
   43|  1.23k|static int32_t mz_stream_read_value(void *stream, uint64_t *value, int32_t len) {
   44|  1.23k|    uint8_t buf[8];
   45|  1.23k|    int32_t n = 0;
   46|  1.23k|    int32_t i = 0;
   47|       |
   48|  1.23k|    *value = 0;
   49|  1.23k|    if (mz_stream_read(stream, buf, len) == len) {
  ------------------
  |  Branch (49:9): [True: 1.02k, False: 210]
  ------------------
   50|  2.29k|        for (n = 0; n < len; n += 1, i += 8)
  ------------------
  |  Branch (50:21): [True: 1.26k, False: 1.02k]
  ------------------
   51|  1.26k|            *value += ((uint64_t)buf[n]) << i;
   52|  1.02k|    } else if (mz_stream_error(stream))
  ------------------
  |  Branch (52:16): [True: 0, False: 210]
  ------------------
   53|      0|        return MZ_STREAM_ERROR;
  ------------------
  |  |   22|      0|#define MZ_STREAM_ERROR                 (-1) /* zlib */
  ------------------
   54|    210|    else
   55|    210|        return MZ_END_OF_STREAM;
  ------------------
  |  |   29|    210|#define MZ_END_OF_STREAM                (-101)
  ------------------
   56|       |
   57|  1.02k|    return MZ_OK;
  ------------------
  |  |   21|  1.02k|#define MZ_OK                           (0)  /* zlib */
  ------------------
   58|  1.23k|}
mz_strm.c:mz_stream_write_value:
  112|  1.13k|static int32_t mz_stream_write_value(void *stream, uint64_t value, int32_t len) {
  113|  1.13k|    uint8_t buf[8];
  114|  1.13k|    int32_t n = 0;
  115|       |
  116|  3.15k|    for (n = 0; n < len; n += 1) {
  ------------------
  |  Branch (116:17): [True: 2.02k, False: 1.13k]
  ------------------
  117|  2.02k|        buf[n] = (uint8_t)(value & 0xff);
  118|  2.02k|        value >>= 8;
  119|  2.02k|    }
  120|       |
  121|  1.13k|    if (value != 0) {
  ------------------
  |  Branch (121:9): [True: 0, False: 1.13k]
  ------------------
  122|       |        /* Data overflow - hack for ZIP64 (X Roche) */
  123|      0|        for (n = 0; n < len; n += 1)
  ------------------
  |  Branch (123:21): [True: 0, False: 0]
  ------------------
  124|      0|            buf[n] = 0xff;
  125|      0|    }
  126|       |
  127|  1.13k|    if (mz_stream_write(stream, buf, len) != len)
  ------------------
  |  Branch (127:9): [True: 295, False: 840]
  ------------------
  128|    295|        return MZ_STREAM_ERROR;
  ------------------
  |  |   22|    295|#define MZ_STREAM_ERROR                 (-1) /* zlib */
  ------------------
  129|       |
  130|    840|    return MZ_OK;
  ------------------
  |  |   21|    840|#define MZ_OK                           (0)  /* zlib */
  ------------------
  131|  1.13k|}

mz_stream_mem_open:
   73|    630|int32_t mz_stream_mem_open(void *stream, const char *path, int32_t mode) {
   74|    630|    mz_stream_mem *mem = (mz_stream_mem *)stream;
   75|    630|    int32_t err = MZ_OK;
  ------------------
  |  |   21|    630|#define MZ_OK                           (0)  /* zlib */
  ------------------
   76|       |
   77|    630|    MZ_UNUSED(path);
  ------------------
  |  |  147|    630|#define MZ_UNUSED(SYMBOL)               ((void)SYMBOL)
  ------------------
   78|       |
   79|    630|    mem->mode = mode;
   80|    630|    mem->limit = 0;
   81|    630|    mem->position = 0;
   82|       |
   83|    630|    if (mem->mode & MZ_OPEN_MODE_CREATE)
  ------------------
  |  |   54|    630|#define MZ_OPEN_MODE_CREATE             (0x08)
  ------------------
  |  Branch (83:9): [True: 630, False: 0]
  ------------------
   84|    630|        err = mz_stream_mem_set_size(stream, mem->grow_size);
   85|      0|    else
   86|      0|        mem->limit = mem->size;
   87|       |
   88|    630|    return err;
   89|    630|}
mz_stream_mem_is_open:
   91|  5.10k|int32_t mz_stream_mem_is_open(void *stream) {
   92|  5.10k|    mz_stream_mem *mem = (mz_stream_mem *)stream;
   93|  5.10k|    if (!mem->buffer)
  ------------------
  |  Branch (93:9): [True: 715, False: 4.38k]
  ------------------
   94|    715|        return MZ_OPEN_ERROR;
  ------------------
  |  |   40|    715|#define MZ_OPEN_ERROR                   (-111)
  ------------------
   95|  4.38k|    return MZ_OK;
  ------------------
  |  |   21|  4.38k|#define MZ_OK                           (0)  /* zlib */
  ------------------
   96|  5.10k|}
mz_stream_mem_read:
   98|  1.23k|int32_t mz_stream_mem_read(void *stream, void *buf, int32_t size) {
   99|  1.23k|    mz_stream_mem *mem = (mz_stream_mem *)stream;
  100|       |
  101|  1.23k|    if (size > mem->size - mem->position)
  ------------------
  |  Branch (101:9): [True: 210, False: 1.02k]
  ------------------
  102|    210|        size = mem->size - mem->position;
  103|  1.23k|    if (mem->position + size > mem->limit)
  ------------------
  |  Branch (103:9): [True: 0, False: 1.23k]
  ------------------
  104|      0|        size = mem->limit - mem->position;
  105|       |
  106|  1.23k|    if (size <= 0)
  ------------------
  |  Branch (106:9): [True: 208, False: 1.02k]
  ------------------
  107|    208|        return 0;
  108|       |
  109|  1.02k|    memcpy(buf, mem->buffer + mem->position, size);
  110|  1.02k|    mem->position += size;
  111|       |
  112|  1.02k|    return size;
  113|  1.23k|}
mz_stream_mem_write:
  115|  1.26k|int32_t mz_stream_mem_write(void *stream, const void *buf, int32_t size) {
  116|  1.26k|    mz_stream_mem *mem = (mz_stream_mem *)stream;
  117|  1.26k|    int32_t new_size = 0;
  118|  1.26k|    int32_t err = MZ_OK;
  ------------------
  |  |   21|  1.26k|#define MZ_OK                           (0)  /* zlib */
  ------------------
  119|       |
  120|  1.26k|    if (!size)
  ------------------
  |  Branch (120:9): [True: 0, False: 1.26k]
  ------------------
  121|      0|        return size;
  122|       |
  123|  1.26k|    if (size > mem->size - mem->position) {
  ------------------
  |  Branch (123:9): [True: 0, False: 1.26k]
  ------------------
  124|      0|        if (mem->mode & MZ_OPEN_MODE_CREATE) {
  ------------------
  |  |   54|      0|#define MZ_OPEN_MODE_CREATE             (0x08)
  ------------------
  |  Branch (124:13): [True: 0, False: 0]
  ------------------
  125|      0|            new_size = mem->size;
  126|      0|            if (size < mem->grow_size)
  ------------------
  |  Branch (126:17): [True: 0, False: 0]
  ------------------
  127|      0|                new_size += mem->grow_size;
  128|      0|            else
  129|      0|                new_size += size;
  130|       |
  131|      0|            err = mz_stream_mem_set_size(stream, new_size);
  132|      0|            if (err != MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (132:17): [True: 0, False: 0]
  ------------------
  133|      0|                return err;
  134|      0|        } else {
  135|      0|            size = mem->size - mem->position;
  136|      0|        }
  137|      0|    }
  138|       |
  139|  1.26k|    memcpy(mem->buffer + mem->position, buf, size);
  140|       |
  141|  1.26k|    mem->position += size;
  142|  1.26k|    if (mem->position > mem->limit)
  ------------------
  |  Branch (142:9): [True: 1.26k, False: 0]
  ------------------
  143|  1.26k|        mem->limit = mem->position;
  144|       |
  145|  1.26k|    return size;
  146|  1.26k|}
mz_stream_mem_tell:
  148|  1.05k|int64_t mz_stream_mem_tell(void *stream) {
  149|  1.05k|    mz_stream_mem *mem = (mz_stream_mem *)stream;
  150|  1.05k|    return mem->position;
  151|  1.05k|}
mz_stream_mem_seek:
  153|    630|int32_t mz_stream_mem_seek(void *stream, int64_t offset, int32_t origin) {
  154|    630|    mz_stream_mem *mem = (mz_stream_mem *)stream;
  155|    630|    int64_t new_pos = 0;
  156|    630|    int32_t err = MZ_OK;
  ------------------
  |  |   21|    630|#define MZ_OK                           (0)  /* zlib */
  ------------------
  157|       |
  158|    630|    switch (origin) {
  159|      0|    case MZ_SEEK_CUR:
  ------------------
  |  |   59|      0|#define MZ_SEEK_CUR                     (1)
  ------------------
  |  Branch (159:5): [True: 0, False: 630]
  ------------------
  160|      0|        new_pos = mem->position + offset;
  161|      0|        break;
  162|    210|    case MZ_SEEK_END:
  ------------------
  |  |   60|    210|#define MZ_SEEK_END                     (2)
  ------------------
  |  Branch (162:5): [True: 210, False: 420]
  ------------------
  163|    210|        new_pos = mem->limit + offset;
  164|    210|        break;
  165|    420|    case MZ_SEEK_SET:
  ------------------
  |  |   58|    420|#define MZ_SEEK_SET                     (0)
  ------------------
  |  Branch (165:5): [True: 420, False: 210]
  ------------------
  166|    420|        new_pos = offset;
  167|    420|        break;
  168|      0|    default:
  ------------------
  |  Branch (168:5): [True: 0, False: 630]
  ------------------
  169|      0|        return MZ_SEEK_ERROR;
  ------------------
  |  |   42|      0|#define MZ_SEEK_ERROR                   (-113)
  ------------------
  170|    630|    }
  171|       |
  172|    630|    if (new_pos > mem->size) {
  ------------------
  |  Branch (172:9): [True: 0, False: 630]
  ------------------
  173|      0|        if ((mem->mode & MZ_OPEN_MODE_CREATE) == 0)
  ------------------
  |  |   54|      0|#define MZ_OPEN_MODE_CREATE             (0x08)
  ------------------
  |  Branch (173:13): [True: 0, False: 0]
  ------------------
  174|      0|            return MZ_SEEK_ERROR;
  ------------------
  |  |   42|      0|#define MZ_SEEK_ERROR                   (-113)
  ------------------
  175|       |
  176|      0|        err = mz_stream_mem_set_size(stream, (int32_t)new_pos);
  177|      0|        if (err != MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (177:13): [True: 0, False: 0]
  ------------------
  178|      0|            return err;
  179|    630|    } else if (new_pos < 0) {
  ------------------
  |  Branch (179:16): [True: 0, False: 630]
  ------------------
  180|      0|        return MZ_SEEK_ERROR;
  ------------------
  |  |   42|      0|#define MZ_SEEK_ERROR                   (-113)
  ------------------
  181|      0|    }
  182|       |
  183|    630|    mem->position = (int32_t)new_pos;
  184|    630|    return MZ_OK;
  ------------------
  |  |   21|    630|#define MZ_OK                           (0)  /* zlib */
  ------------------
  185|    630|}
mz_stream_mem_close:
  187|    630|int32_t mz_stream_mem_close(void *stream) {
  188|    630|    MZ_UNUSED(stream);
  ------------------
  |  |  147|    630|#define MZ_UNUSED(SYMBOL)               ((void)SYMBOL)
  ------------------
  189|       |
  190|       |    /* We never return errors */
  191|    630|    return MZ_OK;
  ------------------
  |  |   21|    630|#define MZ_OK                           (0)  /* zlib */
  ------------------
  192|    630|}
mz_stream_mem_error:
  194|    210|int32_t mz_stream_mem_error(void *stream) {
  195|    210|    MZ_UNUSED(stream);
  ------------------
  |  |  147|    210|#define MZ_UNUSED(SYMBOL)               ((void)SYMBOL)
  ------------------
  196|       |
  197|       |    /* We never return errors */
  198|    210|    return MZ_OK;
  ------------------
  |  |   21|    210|#define MZ_OK                           (0)  /* zlib */
  ------------------
  199|    210|}
mz_stream_mem_set_buffer:
  201|    210|void mz_stream_mem_set_buffer(void *stream, void *buf, int32_t size) {
  202|    210|    mz_stream_mem *mem = (mz_stream_mem *)stream;
  203|    210|    mem->buffer = (uint8_t *)buf;
  204|    210|    mem->size = size;
  205|    210|    mem->limit = size;
  206|    210|}
mz_stream_mem_get_buffer_at:
  212|    840|int32_t mz_stream_mem_get_buffer_at(void *stream, int64_t position, const void **buf) {
  213|    840|    mz_stream_mem *mem = (mz_stream_mem *)stream;
  214|    840|    if (!buf || position < 0 || !mem->buffer|| mem->size < position)
  ------------------
  |  Branch (214:9): [True: 0, False: 840]
  |  Branch (214:17): [True: 0, False: 840]
  |  Branch (214:33): [True: 0, False: 840]
  |  Branch (214:48): [True: 0, False: 840]
  ------------------
  215|      0|        return MZ_SEEK_ERROR;
  ------------------
  |  |   42|      0|#define MZ_SEEK_ERROR                   (-113)
  ------------------
  216|    840|    *buf = mem->buffer + position;
  217|    840|    return MZ_OK;
  ------------------
  |  |   21|    840|#define MZ_OK                           (0)  /* zlib */
  ------------------
  218|    840|}
mz_stream_mem_create:
  240|  1.05k|void *mz_stream_mem_create(void **stream) {
  241|  1.05k|    mz_stream_mem *mem = NULL;
  242|       |
  243|  1.05k|    mem = (mz_stream_mem *)calloc(1, sizeof(mz_stream_mem));
  244|  1.05k|    if (mem) {
  ------------------
  |  Branch (244:9): [True: 1.05k, False: 0]
  ------------------
  245|  1.05k|        mem->stream.vtbl = &mz_stream_mem_vtbl;
  246|  1.05k|        mem->grow_size = 4096;
  247|  1.05k|    }
  248|  1.05k|    if (stream)
  ------------------
  |  Branch (248:9): [True: 1.05k, False: 0]
  ------------------
  249|  1.05k|        *stream = mem;
  250|       |
  251|  1.05k|    return mem;
  252|  1.05k|}
mz_stream_mem_delete:
  254|  1.05k|void mz_stream_mem_delete(void **stream) {
  255|  1.05k|    mz_stream_mem *mem = NULL;
  256|  1.05k|    if (!stream)
  ------------------
  |  Branch (256:9): [True: 0, False: 1.05k]
  ------------------
  257|      0|        return;
  258|  1.05k|    mem = (mz_stream_mem *)*stream;
  259|  1.05k|    if (mem) {
  ------------------
  |  Branch (259:9): [True: 1.05k, False: 0]
  ------------------
  260|  1.05k|        if ((mem->mode & MZ_OPEN_MODE_CREATE) && (mem->buffer))
  ------------------
  |  |   54|  1.05k|#define MZ_OPEN_MODE_CREATE             (0x08)
  ------------------
  |  Branch (260:13): [True: 630, False: 420]
  |  Branch (260:50): [True: 630, False: 0]
  ------------------
  261|    630|            free(mem->buffer);
  262|  1.05k|        free(mem);
  263|  1.05k|    }
  264|  1.05k|    *stream = NULL;
  265|  1.05k|}
mz_strm_mem.c:mz_stream_mem_set_size:
   54|    630|static int32_t mz_stream_mem_set_size(void *stream, int32_t size) {
   55|    630|    mz_stream_mem *mem = (mz_stream_mem *)stream;
   56|    630|    int32_t new_size = size;
   57|    630|    uint8_t *new_buf = NULL;
   58|       |
   59|    630|    new_buf = (uint8_t *)malloc((uint32_t)new_size);
   60|    630|    if (!new_buf)
  ------------------
  |  Branch (60:9): [True: 0, False: 630]
  ------------------
   61|      0|        return MZ_BUF_ERROR;
  ------------------
  |  |   25|      0|#define MZ_BUF_ERROR                    (-5) /* zlib */
  ------------------
   62|       |
   63|    630|    if (mem->buffer) {
  ------------------
  |  Branch (63:9): [True: 0, False: 630]
  ------------------
   64|      0|        memcpy(new_buf, mem->buffer, mem->size);
   65|      0|        free(mem->buffer);
   66|      0|    }
   67|       |
   68|    630|    mem->buffer = new_buf;
   69|    630|    mem->size = new_size;
   70|    630|    return MZ_OK;
  ------------------
  |  |   21|    630|#define MZ_OK                           (0)  /* zlib */
  ------------------
   71|    630|}

mz_zip_create:
 1400|    210|void *mz_zip_create(void **handle) {
 1401|    210|    mz_zip *zip = NULL;
 1402|       |
 1403|    210|    zip = (mz_zip *)calloc(1, sizeof(mz_zip));
 1404|    210|    if (zip)
  ------------------
  |  Branch (1404:9): [True: 210, False: 0]
  ------------------
 1405|    210|        zip->data_descriptor = 1;
 1406|    210|    if (handle)
  ------------------
  |  Branch (1406:9): [True: 210, False: 0]
  ------------------
 1407|    210|        *handle = zip;
 1408|       |
 1409|    210|    return zip;
 1410|    210|}
mz_zip_delete:
 1412|    210|void mz_zip_delete(void **handle) {
 1413|    210|    mz_zip *zip = NULL;
 1414|    210|    if (!handle)
  ------------------
  |  Branch (1414:9): [True: 0, False: 210]
  ------------------
 1415|      0|        return;
 1416|    210|    zip = (mz_zip *)*handle;
 1417|    210|    if (zip) {
  ------------------
  |  Branch (1417:9): [True: 210, False: 0]
  ------------------
 1418|    210|        free(zip);
 1419|    210|    }
 1420|    210|    *handle = NULL;
 1421|    210|}
mz_zip_open:
 1423|    210|int32_t mz_zip_open(void *handle, void *stream, int32_t mode) {
 1424|    210|    mz_zip *zip = (mz_zip *)handle;
 1425|    210|    int32_t err = MZ_OK;
  ------------------
  |  |   21|    210|#define MZ_OK                           (0)  /* zlib */
  ------------------
 1426|       |
 1427|    210|    if (!zip)
  ------------------
  |  Branch (1427:9): [True: 0, False: 210]
  ------------------
 1428|      0|        return MZ_PARAM_ERROR;
  ------------------
  |  |   31|      0|#define MZ_PARAM_ERROR                  (-102)
  ------------------
 1429|       |
 1430|    210|    mz_zip_print("Zip - Open\n");
 1431|       |
 1432|    210|    zip->stream = stream;
 1433|       |
 1434|    210|    mz_stream_mem_create(&zip->cd_mem_stream);
 1435|       |
 1436|    210|    if (mode & MZ_OPEN_MODE_WRITE) {
  ------------------
  |  |   51|    210|#define MZ_OPEN_MODE_WRITE              (0x02)
  ------------------
  |  Branch (1436:9): [True: 210, False: 0]
  ------------------
 1437|    210|        mz_stream_mem_open(zip->cd_mem_stream, NULL, MZ_OPEN_MODE_CREATE);
  ------------------
  |  |   54|    210|#define MZ_OPEN_MODE_CREATE             (0x08)
  ------------------
 1438|    210|        zip->cd_stream = zip->cd_mem_stream;
 1439|    210|    } else {
 1440|      0|        zip->cd_stream = stream;
 1441|      0|    }
 1442|       |
 1443|    210|    if ((mode & MZ_OPEN_MODE_READ) || (mode & MZ_OPEN_MODE_APPEND)) {
  ------------------
  |  |   50|    210|#define MZ_OPEN_MODE_READ               (0x01)
  ------------------
                  if ((mode & MZ_OPEN_MODE_READ) || (mode & MZ_OPEN_MODE_APPEND)) {
  ------------------
  |  |   53|    210|#define MZ_OPEN_MODE_APPEND             (0x04)
  ------------------
  |  Branch (1443:9): [True: 0, False: 210]
  |  Branch (1443:39): [True: 0, False: 210]
  ------------------
 1444|      0|        if ((mode & MZ_OPEN_MODE_CREATE) == 0) {
  ------------------
  |  |   54|      0|#define MZ_OPEN_MODE_CREATE             (0x08)
  ------------------
  |  Branch (1444:13): [True: 0, False: 0]
  ------------------
 1445|      0|            err = mz_zip_read_cd(zip);
 1446|      0|            if (err != MZ_OK) {
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (1446:17): [True: 0, False: 0]
  ------------------
 1447|      0|                mz_zip_print("Zip - Error detected reading cd (%" PRId32 ")\n", err);
 1448|      0|                if (zip->recover && mz_zip_recover_cd(zip) == MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (1448:21): [True: 0, False: 0]
  |  Branch (1448:37): [True: 0, False: 0]
  ------------------
 1449|      0|                    err = MZ_OK;
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
 1450|      0|            }
 1451|      0|        }
 1452|       |
 1453|      0|        if ((err == MZ_OK) && (mode & MZ_OPEN_MODE_APPEND)) {
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
                      if ((err == MZ_OK) && (mode & MZ_OPEN_MODE_APPEND)) {
  ------------------
  |  |   53|      0|#define MZ_OPEN_MODE_APPEND             (0x04)
  ------------------
  |  Branch (1453:13): [True: 0, False: 0]
  |  Branch (1453:31): [True: 0, False: 0]
  ------------------
 1454|      0|            if (zip->cd_size > 0) {
  ------------------
  |  Branch (1454:17): [True: 0, False: 0]
  ------------------
 1455|       |                /* Store central directory in memory */
 1456|      0|                err = mz_stream_seek(zip->stream, zip->cd_offset, MZ_SEEK_SET);
  ------------------
  |  |   58|      0|#define MZ_SEEK_SET                     (0)
  ------------------
 1457|      0|                if (err == MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (1457:21): [True: 0, False: 0]
  ------------------
 1458|      0|                    err = mz_stream_copy(zip->cd_mem_stream, zip->stream, (int32_t)zip->cd_size);
 1459|      0|                if (err == MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (1459:21): [True: 0, False: 0]
  ------------------
 1460|      0|                    err = mz_stream_seek(zip->stream, zip->cd_offset, MZ_SEEK_SET);
  ------------------
  |  |   58|      0|#define MZ_SEEK_SET                     (0)
  ------------------
 1461|      0|            } else {
 1462|      0|                if (zip->cd_signature == MZ_ZIP_MAGIC_ENDHEADER) {
  ------------------
  |  |   62|      0|#define MZ_ZIP_MAGIC_ENDHEADER          (0x06054b50)
  ------------------
  |  Branch (1462:21): [True: 0, False: 0]
  ------------------
 1463|       |                    /* If tiny zip then overwrite end header */
 1464|      0|                    err = mz_stream_seek(zip->stream, zip->cd_offset, MZ_SEEK_SET);
  ------------------
  |  |   58|      0|#define MZ_SEEK_SET                     (0)
  ------------------
 1465|      0|                } else {
 1466|       |                    /* If no central directory, append new zip to end of file */
 1467|      0|                    err = mz_stream_seek(zip->stream, 0, MZ_SEEK_END);
  ------------------
  |  |   60|      0|#define MZ_SEEK_END                     (2)
  ------------------
 1468|      0|                }
 1469|      0|            }
 1470|       |
 1471|      0|            if (zip->disk_number_with_cd > 0) {
  ------------------
  |  Branch (1471:17): [True: 0, False: 0]
  ------------------
 1472|       |                /* Move to last disk to begin appending */
 1473|      0|                mz_stream_set_prop_int64(zip->stream, MZ_STREAM_PROP_DISK_NUMBER, zip->disk_number_with_cd - 1);
  ------------------
  |  |   27|      0|#define MZ_STREAM_PROP_DISK_NUMBER          (8)
  ------------------
 1474|      0|            }
 1475|      0|        } else {
 1476|      0|            zip->cd_start_pos = zip->cd_offset;
 1477|      0|        }
 1478|      0|    }
 1479|       |
 1480|    210|    if (err != MZ_OK) {
  ------------------
  |  |   21|    210|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (1480:9): [True: 0, False: 210]
  ------------------
 1481|      0|        mz_zip_close(zip);
 1482|      0|        return err;
 1483|      0|    }
 1484|       |
 1485|       |    /* Memory streams used to store variable length file info data */
 1486|    210|    mz_stream_mem_create(&zip->file_info_stream);
 1487|    210|    mz_stream_mem_open(zip->file_info_stream, NULL, MZ_OPEN_MODE_CREATE);
  ------------------
  |  |   54|    210|#define MZ_OPEN_MODE_CREATE             (0x08)
  ------------------
 1488|       |
 1489|    210|    mz_stream_mem_create(&zip->local_file_info_stream);
 1490|    210|    mz_stream_mem_open(zip->local_file_info_stream, NULL, MZ_OPEN_MODE_CREATE);
  ------------------
  |  |   54|    210|#define MZ_OPEN_MODE_CREATE             (0x08)
  ------------------
 1491|       |
 1492|    210|    zip->open_mode = mode;
 1493|       |
 1494|    210|    return err;
 1495|    210|}
mz_zip_close:
 1497|    210|int32_t mz_zip_close(void *handle) {
 1498|    210|    mz_zip *zip = (mz_zip *)handle;
 1499|    210|    int32_t err = MZ_OK;
  ------------------
  |  |   21|    210|#define MZ_OK                           (0)  /* zlib */
  ------------------
 1500|       |
 1501|    210|    if (!zip)
  ------------------
  |  Branch (1501:9): [True: 0, False: 210]
  ------------------
 1502|      0|        return MZ_PARAM_ERROR;
  ------------------
  |  |   31|      0|#define MZ_PARAM_ERROR                  (-102)
  ------------------
 1503|       |
 1504|    210|    mz_zip_print("Zip - Close\n");
 1505|       |
 1506|    210|    if (mz_zip_entry_is_open(handle) == MZ_OK)
  ------------------
  |  |   21|    210|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (1506:9): [True: 0, False: 210]
  ------------------
 1507|      0|        err = mz_zip_entry_close(handle);
 1508|       |
 1509|    210|    if ((err == MZ_OK) && (zip->open_mode & MZ_OPEN_MODE_WRITE))
  ------------------
  |  |   21|    210|#define MZ_OK                           (0)  /* zlib */
  ------------------
                  if ((err == MZ_OK) && (zip->open_mode & MZ_OPEN_MODE_WRITE))
  ------------------
  |  |   51|    210|#define MZ_OPEN_MODE_WRITE              (0x02)
  ------------------
  |  Branch (1509:9): [True: 210, False: 0]
  |  Branch (1509:27): [True: 210, False: 0]
  ------------------
 1510|    210|        err = mz_zip_write_cd(handle);
 1511|       |
 1512|    210|    if (zip->cd_mem_stream) {
  ------------------
  |  Branch (1512:9): [True: 210, False: 0]
  ------------------
 1513|    210|        mz_stream_close(zip->cd_mem_stream);
 1514|    210|        mz_stream_delete(&zip->cd_mem_stream);
 1515|    210|    }
 1516|       |
 1517|    210|    if (zip->file_info_stream) {
  ------------------
  |  Branch (1517:9): [True: 210, False: 0]
  ------------------
 1518|    210|        mz_stream_mem_close(zip->file_info_stream);
 1519|    210|        mz_stream_mem_delete(&zip->file_info_stream);
 1520|    210|    }
 1521|    210|    if (zip->local_file_info_stream) {
  ------------------
  |  Branch (1521:9): [True: 210, False: 0]
  ------------------
 1522|    210|        mz_stream_mem_close(zip->local_file_info_stream);
 1523|    210|        mz_stream_mem_delete(&zip->local_file_info_stream);
 1524|    210|    }
 1525|       |
 1526|    210|    if (zip->comment) {
  ------------------
  |  Branch (1526:9): [True: 0, False: 210]
  ------------------
 1527|      0|        free(zip->comment);
 1528|      0|        zip->comment = NULL;
 1529|      0|    }
 1530|       |
 1531|    210|    zip->stream = NULL;
 1532|    210|    zip->cd_stream = NULL;
 1533|       |
 1534|    210|    return err;
 1535|    210|}
mz_zip_entry_is_open:
 1842|    420|int32_t mz_zip_entry_is_open(void *handle) {
 1843|    420|    mz_zip *zip = (mz_zip *)handle;
 1844|    420|    if (!zip)
  ------------------
  |  Branch (1844:9): [True: 0, False: 420]
  ------------------
 1845|      0|        return MZ_PARAM_ERROR;
  ------------------
  |  |   31|      0|#define MZ_PARAM_ERROR                  (-102)
  ------------------
 1846|    420|    if (zip->entry_opened == 0)
  ------------------
  |  Branch (1846:9): [True: 420, False: 0]
  ------------------
 1847|    420|        return MZ_EXIST_ERROR;
  ------------------
  |  |   36|    420|#define MZ_EXIST_ERROR                  (-107)
  ------------------
 1848|      0|    return MZ_OK;
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
 1849|    420|}
mz_zip_entry_write_open:
 1892|    210|int32_t mz_zip_entry_write_open(void *handle, const mz_zip_file *file_info, int16_t compress_level, uint8_t raw, const char *password) {
 1893|    210|    mz_zip *zip = (mz_zip *)handle;
 1894|    210|    int64_t filename_pos = -1;
 1895|    210|    int64_t extrafield_pos = 0;
 1896|    210|    int64_t comment_pos = 0;
 1897|    210|    int64_t linkname_pos = 0;
 1898|    210|    int64_t disk_number = 0;
 1899|    210|    uint8_t is_dir = 0;
 1900|    210|    int32_t err = MZ_OK;
  ------------------
  |  |   21|    210|#define MZ_OK                           (0)  /* zlib */
  ------------------
 1901|       |
 1902|       |#if defined(MZ_ZIP_NO_ENCRYPTION)
 1903|       |    if (password)
 1904|       |        return MZ_SUPPORT_ERROR;
 1905|       |#endif
 1906|    210|    if (!zip || !file_info || !file_info->filename)
  ------------------
  |  Branch (1906:9): [True: 0, False: 210]
  |  Branch (1906:17): [True: 0, False: 210]
  |  Branch (1906:31): [True: 0, False: 210]
  ------------------
 1907|      0|        return MZ_PARAM_ERROR;
  ------------------
  |  |   31|      0|#define MZ_PARAM_ERROR                  (-102)
  ------------------
 1908|       |
 1909|    210|    if (mz_zip_entry_is_open(handle) == MZ_OK) {
  ------------------
  |  |   21|    210|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (1909:9): [True: 0, False: 210]
  ------------------
 1910|      0|        err = mz_zip_entry_close(handle);
 1911|      0|        if (err != MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (1911:13): [True: 0, False: 0]
  ------------------
 1912|      0|            return err;
 1913|      0|    }
 1914|       |
 1915|    210|    memcpy(&zip->file_info, file_info, sizeof(mz_zip_file));
 1916|       |
 1917|    210|    mz_zip_print("Zip - Entry - Write open - %s (level %" PRId16 " raw %" PRId8 ")\n",
 1918|    210|        zip->file_info.filename, compress_level, raw);
 1919|       |
 1920|    210|    mz_stream_seek(zip->file_info_stream, 0, MZ_SEEK_SET);
  ------------------
  |  |   58|    210|#define MZ_SEEK_SET                     (0)
  ------------------
 1921|    210|    mz_stream_write(zip->file_info_stream, file_info, sizeof(mz_zip_file));
 1922|       |
 1923|       |    /* Copy filename, extrafield, and comment internally */
 1924|    210|    filename_pos = mz_stream_tell(zip->file_info_stream);
 1925|    210|    if (file_info->filename)
  ------------------
  |  Branch (1925:9): [True: 210, False: 0]
  ------------------
 1926|    210|        mz_stream_write(zip->file_info_stream, file_info->filename, (int32_t)strlen(file_info->filename));
 1927|    210|    mz_stream_write_uint8(zip->file_info_stream, 0);
 1928|       |
 1929|    210|    extrafield_pos = mz_stream_tell(zip->file_info_stream);
 1930|    210|    if (file_info->extrafield)
  ------------------
  |  Branch (1930:9): [True: 0, False: 210]
  ------------------
 1931|      0|        mz_stream_write(zip->file_info_stream, file_info->extrafield, file_info->extrafield_size);
 1932|    210|    mz_stream_write_uint8(zip->file_info_stream, 0);
 1933|       |
 1934|    210|    comment_pos = mz_stream_tell(zip->file_info_stream);
 1935|    210|    if (file_info->comment)
  ------------------
  |  Branch (1935:9): [True: 0, False: 210]
  ------------------
 1936|      0|        mz_stream_write(zip->file_info_stream, file_info->comment, file_info->comment_size);
 1937|    210|    mz_stream_write_uint8(zip->file_info_stream, 0);
 1938|       |
 1939|    210|    linkname_pos = mz_stream_tell(zip->file_info_stream);
 1940|    210|    if (file_info->linkname)
  ------------------
  |  Branch (1940:9): [True: 0, False: 210]
  ------------------
 1941|      0|        mz_stream_write(zip->file_info_stream, file_info->linkname, (int32_t)strlen(file_info->linkname));
 1942|    210|    mz_stream_write_uint8(zip->file_info_stream, 0);
 1943|       |
 1944|    210|    mz_stream_mem_get_buffer_at(zip->file_info_stream, filename_pos, (const void **)&zip->file_info.filename);
 1945|    210|    mz_stream_mem_get_buffer_at(zip->file_info_stream, extrafield_pos, (const void **)&zip->file_info.extrafield);
 1946|    210|    mz_stream_mem_get_buffer_at(zip->file_info_stream, comment_pos, (const void **)&zip->file_info.comment);
 1947|    210|    mz_stream_mem_get_buffer_at(zip->file_info_stream, linkname_pos, (const void **)&zip->file_info.linkname);
 1948|       |
 1949|    210|    if (zip->file_info.compression_method == MZ_COMPRESS_METHOD_DEFLATE) {
  ------------------
  |  |   64|    210|#define MZ_COMPRESS_METHOD_DEFLATE      (8)
  ------------------
  |  Branch (1949:9): [True: 78, False: 132]
  ------------------
 1950|     78|        if ((compress_level == 8) || (compress_level == 9))
  ------------------
  |  Branch (1950:13): [True: 1, False: 77]
  |  Branch (1950:38): [True: 1, False: 76]
  ------------------
 1951|      2|            zip->file_info.flag |= MZ_ZIP_FLAG_DEFLATE_MAX;
  ------------------
  |  |   79|      2|#define MZ_ZIP_FLAG_DEFLATE_MAX         (1 << 1)
  ------------------
 1952|     78|        if (compress_level == 2)
  ------------------
  |  Branch (1952:13): [True: 1, False: 77]
  ------------------
 1953|      1|            zip->file_info.flag |= MZ_ZIP_FLAG_DEFLATE_FAST;
  ------------------
  |  |   81|      1|#define MZ_ZIP_FLAG_DEFLATE_FAST        (1 << 2)
  ------------------
 1954|     78|        if (compress_level == 1)
  ------------------
  |  Branch (1954:13): [True: 2, False: 76]
  ------------------
 1955|      2|            zip->file_info.flag |= MZ_ZIP_FLAG_DEFLATE_SUPER_FAST;
  ------------------
  |  |   82|      2|#define MZ_ZIP_FLAG_DEFLATE_SUPER_FAST  (MZ_ZIP_FLAG_DEFLATE_FAST | \
  |  |  ------------------
  |  |  |  |   81|      2|#define MZ_ZIP_FLAG_DEFLATE_FAST        (1 << 2)
  |  |  ------------------
  |  |   83|      2|                                         MZ_ZIP_FLAG_DEFLATE_MAX)
  |  |  ------------------
  |  |  |  |   79|      2|#define MZ_ZIP_FLAG_DEFLATE_MAX         (1 << 1)
  |  |  ------------------
  ------------------
 1956|     78|    }
 1957|       |#if defined(HAVE_LZMA) || defined(HAVE_LIBCOMP)
 1958|       |    else if (zip->file_info.compression_method == MZ_COMPRESS_METHOD_LZMA ||
 1959|       |             zip->file_info.compression_method == MZ_COMPRESS_METHOD_XZ)
 1960|       |        zip->file_info.flag |= MZ_ZIP_FLAG_LZMA_EOS_MARKER;
 1961|       |#endif
 1962|       |
 1963|    210|    if (mz_zip_attrib_is_dir(zip->file_info.external_fa, zip->file_info.version_madeby) == MZ_OK)
  ------------------
  |  |   21|    210|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (1963:9): [True: 0, False: 210]
  ------------------
 1964|      0|        is_dir = 1;
 1965|       |
 1966|    210|    if (!is_dir) {
  ------------------
  |  Branch (1966:9): [True: 210, False: 0]
  ------------------
 1967|    210|        if (zip->data_descriptor)
  ------------------
  |  Branch (1967:13): [True: 210, False: 0]
  ------------------
 1968|    210|            zip->file_info.flag |= MZ_ZIP_FLAG_DATA_DESCRIPTOR;
  ------------------
  |  |   84|    210|#define MZ_ZIP_FLAG_DATA_DESCRIPTOR     (1 << 3)
  ------------------
 1969|    210|        if (password)
  ------------------
  |  Branch (1969:13): [True: 0, False: 210]
  ------------------
 1970|      0|            zip->file_info.flag |= MZ_ZIP_FLAG_ENCRYPTED;
  ------------------
  |  |   77|      0|#define MZ_ZIP_FLAG_ENCRYPTED           (1 << 0)
  ------------------
 1971|    210|    }
 1972|       |
 1973|    210|    mz_stream_get_prop_int64(zip->stream, MZ_STREAM_PROP_DISK_NUMBER, &disk_number);
  ------------------
  |  |   27|    210|#define MZ_STREAM_PROP_DISK_NUMBER          (8)
  ------------------
 1974|    210|    zip->file_info.disk_number = (uint32_t)disk_number;
 1975|    210|    zip->file_info.disk_offset = mz_stream_tell(zip->stream);
 1976|       |
 1977|    210|    if (zip->file_info.flag & MZ_ZIP_FLAG_ENCRYPTED) {
  ------------------
  |  |   77|    210|#define MZ_ZIP_FLAG_ENCRYPTED           (1 << 0)
  ------------------
  |  Branch (1977:9): [True: 13, False: 197]
  ------------------
 1978|     13|#ifdef HAVE_PKCRYPT
 1979|       |        /* Pre-calculated CRC value is required for PKWARE traditional encryption */
 1980|     13|        uint32_t dos_date = mz_zip_time_t_to_dos_date(zip->file_info.modified_date);
 1981|     13|        zip->file_info.pk_verify = mz_zip_get_pk_verify(dos_date, zip->file_info.crc, zip->file_info.flag);
 1982|     13|#endif
 1983|     13|#ifdef HAVE_WZAES
 1984|     13|        if (zip->file_info.aes_version && zip->file_info.aes_encryption_mode == 0)
  ------------------
  |  Branch (1984:13): [True: 0, False: 13]
  |  Branch (1984:43): [True: 0, False: 0]
  ------------------
 1985|      0|            zip->file_info.aes_encryption_mode = MZ_AES_ENCRYPTION_MODE_256;
  ------------------
  |  |  117|      0|#define MZ_AES_ENCRYPTION_MODE_256      (0x03)
  ------------------
 1986|     13|#endif
 1987|     13|    }
 1988|       |
 1989|    210|    zip->file_info.crc = 0;
 1990|    210|    zip->file_info.compressed_size = 0;
 1991|       |
 1992|    210|    if ((compress_level == 0) || (is_dir))
  ------------------
  |  Branch (1992:9): [True: 6, False: 204]
  |  Branch (1992:34): [True: 0, False: 204]
  ------------------
 1993|      6|        zip->file_info.compression_method = MZ_COMPRESS_METHOD_STORE;
  ------------------
  |  |   63|      6|#define MZ_COMPRESS_METHOD_STORE        (0)
  ------------------
 1994|       |
 1995|    210|#ifdef MZ_ZIP_NO_COMPRESSION
 1996|    210|    if (zip->file_info.compression_method != MZ_COMPRESS_METHOD_STORE)
  ------------------
  |  |   63|    210|#define MZ_COMPRESS_METHOD_STORE        (0)
  ------------------
  |  Branch (1996:9): [True: 125, False: 85]
  ------------------
 1997|    125|        err = MZ_SUPPORT_ERROR;
  ------------------
  |  |   38|    125|#define MZ_SUPPORT_ERROR                (-109)
  ------------------
 1998|    210|#endif
 1999|    210|    if (err == MZ_OK)
  ------------------
  |  |   21|    210|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (1999:9): [True: 85, False: 125]
  ------------------
 2000|     85|        err = mz_zip_entry_write_header(zip->stream, 1, &zip->file_info);
 2001|    210|    if (err == MZ_OK)
  ------------------
  |  |   21|    210|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (2001:9): [True: 0, False: 210]
  ------------------
 2002|      0|        err = mz_zip_entry_open_int(handle, raw, compress_level, password);
 2003|       |
 2004|    210|    return err;
 2005|    210|}
mz_zip_attrib_is_dir:
 2463|    347|int32_t mz_zip_attrib_is_dir(uint32_t attrib, int32_t version_madeby) {
 2464|    347|    uint32_t posix_attrib = 0;
 2465|    347|    uint8_t system = MZ_HOST_SYSTEM(version_madeby);
  ------------------
  |  |  103|    347|#define MZ_HOST_SYSTEM(VERSION_MADEBY)  ((uint8_t)(VERSION_MADEBY >> 8))
  ------------------
 2466|    347|    int32_t err = MZ_OK;
  ------------------
  |  |   21|    347|#define MZ_OK                           (0)  /* zlib */
  ------------------
 2467|       |
 2468|    347|    err = mz_zip_attrib_convert(system, attrib, MZ_HOST_SYSTEM_UNIX, &posix_attrib);
  ------------------
  |  |  105|    347|#define MZ_HOST_SYSTEM_UNIX             (3)
  ------------------
 2469|    347|    if (err == MZ_OK) {
  ------------------
  |  |   21|    347|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (2469:9): [True: 347, False: 0]
  ------------------
 2470|    347|        if ((posix_attrib & 0170000) == 0040000) /* S_ISDIR */
  ------------------
  |  Branch (2470:13): [True: 0, False: 347]
  ------------------
 2471|      0|            return MZ_OK;
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
 2472|    347|    }
 2473|       |
 2474|    347|    return MZ_EXIST_ERROR;
  ------------------
  |  |   36|    347|#define MZ_EXIST_ERROR                  (-107)
  ------------------
 2475|    347|}
mz_zip_attrib_convert:
 2491|    347|int32_t mz_zip_attrib_convert(uint8_t src_sys, uint32_t src_attrib, uint8_t target_sys, uint32_t *target_attrib) {
 2492|    347|    if (!target_attrib)
  ------------------
  |  Branch (2492:9): [True: 0, False: 347]
  ------------------
 2493|      0|        return MZ_PARAM_ERROR;
  ------------------
  |  |   31|      0|#define MZ_PARAM_ERROR                  (-102)
  ------------------
 2494|       |
 2495|    347|    *target_attrib = 0;
 2496|       |
 2497|    347|    if ((src_sys == MZ_HOST_SYSTEM_MSDOS) || (src_sys == MZ_HOST_SYSTEM_WINDOWS_NTFS)) {
  ------------------
  |  |  104|    347|#define MZ_HOST_SYSTEM_MSDOS            (0)
  ------------------
                  if ((src_sys == MZ_HOST_SYSTEM_MSDOS) || (src_sys == MZ_HOST_SYSTEM_WINDOWS_NTFS)) {
  ------------------
  |  |  106|      0|#define MZ_HOST_SYSTEM_WINDOWS_NTFS     (10)
  ------------------
  |  Branch (2497:9): [True: 347, False: 0]
  |  Branch (2497:46): [True: 0, False: 0]
  ------------------
 2498|    347|        if ((target_sys == MZ_HOST_SYSTEM_MSDOS) || (target_sys == MZ_HOST_SYSTEM_WINDOWS_NTFS)) {
  ------------------
  |  |  104|    347|#define MZ_HOST_SYSTEM_MSDOS            (0)
  ------------------
                      if ((target_sys == MZ_HOST_SYSTEM_MSDOS) || (target_sys == MZ_HOST_SYSTEM_WINDOWS_NTFS)) {
  ------------------
  |  |  106|    347|#define MZ_HOST_SYSTEM_WINDOWS_NTFS     (10)
  ------------------
  |  Branch (2498:13): [True: 0, False: 347]
  |  Branch (2498:53): [True: 0, False: 347]
  ------------------
 2499|      0|            *target_attrib = src_attrib;
 2500|      0|            return MZ_OK;
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
 2501|      0|        }
 2502|    347|        if ((target_sys == MZ_HOST_SYSTEM_UNIX) || (target_sys == MZ_HOST_SYSTEM_OSX_DARWIN) || (target_sys == MZ_HOST_SYSTEM_RISCOS))
  ------------------
  |  |  105|    347|#define MZ_HOST_SYSTEM_UNIX             (3)
  ------------------
                      if ((target_sys == MZ_HOST_SYSTEM_UNIX) || (target_sys == MZ_HOST_SYSTEM_OSX_DARWIN) || (target_sys == MZ_HOST_SYSTEM_RISCOS))
  ------------------
  |  |  108|      0|#define MZ_HOST_SYSTEM_OSX_DARWIN       (19)
  ------------------
                      if ((target_sys == MZ_HOST_SYSTEM_UNIX) || (target_sys == MZ_HOST_SYSTEM_OSX_DARWIN) || (target_sys == MZ_HOST_SYSTEM_RISCOS))
  ------------------
  |  |  107|      0|#define MZ_HOST_SYSTEM_RISCOS           (13)
  ------------------
  |  Branch (2502:13): [True: 347, False: 0]
  |  Branch (2502:52): [True: 0, False: 0]
  |  Branch (2502:97): [True: 0, False: 0]
  ------------------
 2503|    347|            return mz_zip_attrib_win32_to_posix(src_attrib, target_attrib);
 2504|    347|    } else if ((src_sys == MZ_HOST_SYSTEM_UNIX) || (src_sys == MZ_HOST_SYSTEM_OSX_DARWIN) || (src_sys == MZ_HOST_SYSTEM_RISCOS)) {
  ------------------
  |  |  105|      0|#define MZ_HOST_SYSTEM_UNIX             (3)
  ------------------
                  } else if ((src_sys == MZ_HOST_SYSTEM_UNIX) || (src_sys == MZ_HOST_SYSTEM_OSX_DARWIN) || (src_sys == MZ_HOST_SYSTEM_RISCOS)) {
  ------------------
  |  |  108|      0|#define MZ_HOST_SYSTEM_OSX_DARWIN       (19)
  ------------------
                  } else if ((src_sys == MZ_HOST_SYSTEM_UNIX) || (src_sys == MZ_HOST_SYSTEM_OSX_DARWIN) || (src_sys == MZ_HOST_SYSTEM_RISCOS)) {
  ------------------
  |  |  107|      0|#define MZ_HOST_SYSTEM_RISCOS           (13)
  ------------------
  |  Branch (2504:16): [True: 0, False: 0]
  |  Branch (2504:52): [True: 0, False: 0]
  |  Branch (2504:94): [True: 0, False: 0]
  ------------------
 2505|       |        /* If high bytes are set, it contains unix specific attributes */
 2506|      0|        if ((src_attrib >> 16) != 0)
  ------------------
  |  Branch (2506:13): [True: 0, False: 0]
  ------------------
 2507|      0|            src_attrib >>= 16;
 2508|       |
 2509|      0|        if ((target_sys == MZ_HOST_SYSTEM_UNIX) || (target_sys == MZ_HOST_SYSTEM_OSX_DARWIN) || (target_sys == MZ_HOST_SYSTEM_RISCOS)) {
  ------------------
  |  |  105|      0|#define MZ_HOST_SYSTEM_UNIX             (3)
  ------------------
                      if ((target_sys == MZ_HOST_SYSTEM_UNIX) || (target_sys == MZ_HOST_SYSTEM_OSX_DARWIN) || (target_sys == MZ_HOST_SYSTEM_RISCOS)) {
  ------------------
  |  |  108|      0|#define MZ_HOST_SYSTEM_OSX_DARWIN       (19)
  ------------------
                      if ((target_sys == MZ_HOST_SYSTEM_UNIX) || (target_sys == MZ_HOST_SYSTEM_OSX_DARWIN) || (target_sys == MZ_HOST_SYSTEM_RISCOS)) {
  ------------------
  |  |  107|      0|#define MZ_HOST_SYSTEM_RISCOS           (13)
  ------------------
  |  Branch (2509:13): [True: 0, False: 0]
  |  Branch (2509:52): [True: 0, False: 0]
  |  Branch (2509:97): [True: 0, False: 0]
  ------------------
 2510|      0|            *target_attrib = src_attrib;
 2511|      0|            return MZ_OK;
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
 2512|      0|        }
 2513|      0|        if ((target_sys == MZ_HOST_SYSTEM_MSDOS) || (target_sys == MZ_HOST_SYSTEM_WINDOWS_NTFS))
  ------------------
  |  |  104|      0|#define MZ_HOST_SYSTEM_MSDOS            (0)
  ------------------
                      if ((target_sys == MZ_HOST_SYSTEM_MSDOS) || (target_sys == MZ_HOST_SYSTEM_WINDOWS_NTFS))
  ------------------
  |  |  106|      0|#define MZ_HOST_SYSTEM_WINDOWS_NTFS     (10)
  ------------------
  |  Branch (2513:13): [True: 0, False: 0]
  |  Branch (2513:53): [True: 0, False: 0]
  ------------------
 2514|      0|            return mz_zip_attrib_posix_to_win32(src_attrib, target_attrib);
 2515|      0|    }
 2516|       |
 2517|      0|    return MZ_SUPPORT_ERROR;
  ------------------
  |  |   38|      0|#define MZ_SUPPORT_ERROR                (-109)
  ------------------
 2518|    347|}
mz_zip_attrib_win32_to_posix:
 2542|    347|int32_t mz_zip_attrib_win32_to_posix(uint32_t win32_attrib, uint32_t *posix_attrib) {
 2543|    347|    if (!posix_attrib)
  ------------------
  |  Branch (2543:9): [True: 0, False: 347]
  ------------------
 2544|      0|        return MZ_PARAM_ERROR;
  ------------------
  |  |   31|      0|#define MZ_PARAM_ERROR                  (-102)
  ------------------
 2545|       |
 2546|    347|    *posix_attrib = 0000444;        /* S_IRUSR | S_IRGRP | S_IROTH */
 2547|       |    /* FILE_ATTRIBUTE_READONLY */
 2548|    347|    if ((win32_attrib & 0x01) == 0)
  ------------------
  |  Branch (2548:9): [True: 347, False: 0]
  ------------------
 2549|    347|        *posix_attrib |= 0000222;   /* S_IWUSR | S_IWGRP | S_IWOTH */
 2550|       |    /* FILE_ATTRIBUTE_REPARSE_POINT */
 2551|    347|    if ((win32_attrib & 0x400) == 0x400)
  ------------------
  |  Branch (2551:9): [True: 0, False: 347]
  ------------------
 2552|      0|        *posix_attrib |= 0120000;   /* S_IFLNK */
 2553|       |    /* FILE_ATTRIBUTE_DIRECTORY */
 2554|    347|    else if ((win32_attrib & 0x10) == 0x10)
  ------------------
  |  Branch (2554:14): [True: 0, False: 347]
  ------------------
 2555|      0|        *posix_attrib |= 0040111;   /* S_IFDIR | S_IXUSR | S_IXGRP | S_IXOTH */
 2556|    347|    else
 2557|    347|        *posix_attrib |= 0100000;   /* S_IFREG */
 2558|       |
 2559|    347|    return MZ_OK;
  ------------------
  |  |   21|    347|#define MZ_OK                           (0)  /* zlib */
  ------------------
 2560|    347|}
mz_zip_time_t_to_tm:
 2676|     13|int32_t mz_zip_time_t_to_tm(time_t unix_time, struct tm *ptm) {
 2677|     13|    struct tm ltm;
 2678|     13|    if (!ptm)
  ------------------
  |  Branch (2678:9): [True: 0, False: 13]
  ------------------
 2679|      0|        return MZ_PARAM_ERROR;
  ------------------
  |  |   31|      0|#define MZ_PARAM_ERROR                  (-102)
  ------------------
 2680|     13|    if (!localtime_r(&unix_time, &ltm)) { /* Returns a 1900-based year */
  ------------------
  |  Branch (2680:9): [True: 0, False: 13]
  ------------------
 2681|       |        /* Invalid date stored, so don't return it */
 2682|      0|        memset(ptm, 0, sizeof(struct tm));
 2683|      0|        return MZ_INTERNAL_ERROR;
  ------------------
  |  |   33|      0|#define MZ_INTERNAL_ERROR               (-104)
  ------------------
 2684|      0|    }
 2685|     13|    memcpy(ptm, &ltm, sizeof(struct tm));
 2686|     13|    return MZ_OK;
  ------------------
  |  |   21|     13|#define MZ_OK                           (0)  /* zlib */
  ------------------
 2687|     13|}
mz_zip_time_t_to_dos_date:
 2689|     13|uint32_t mz_zip_time_t_to_dos_date(time_t unix_time) {
 2690|     13|    struct tm ptm;
 2691|     13|    mz_zip_time_t_to_tm(unix_time, &ptm);
 2692|     13|    return mz_zip_tm_to_dosdate((const struct tm *)&ptm);
 2693|     13|}
mz_zip_tm_to_dosdate:
 2695|     13|uint32_t mz_zip_tm_to_dosdate(const struct tm *ptm) {
 2696|     13|    struct tm fixed_tm;
 2697|       |
 2698|       |    /* Years supported: */
 2699|       |
 2700|       |    /* [00, 79]      (assumed to be between 2000 and 2079) */
 2701|       |    /* [80, 207]     (assumed to be between 1980 and 2107, typical output of old */
 2702|       |    /*                software that does 'year-1900' to get a double digit year) */
 2703|       |    /* [1980, 2107]  (due to format limitations, only years 1980-2107 can be stored.) */
 2704|       |
 2705|     13|    memcpy(&fixed_tm, ptm, sizeof(struct tm));
 2706|     13|    if (fixed_tm.tm_year >= 1980) /* range [1980, 2107] */
  ------------------
  |  Branch (2706:9): [True: 0, False: 13]
  ------------------
 2707|      0|        fixed_tm.tm_year -= 1980;
 2708|     13|    else if (fixed_tm.tm_year >= 80) /* range [80, 207] */
  ------------------
  |  Branch (2708:14): [True: 0, False: 13]
  ------------------
 2709|      0|        fixed_tm.tm_year -= 80;
 2710|     13|    else /* range [00, 79] */
 2711|     13|        fixed_tm.tm_year += 20;
 2712|       |
 2713|     13|    if (mz_zip_invalid_date(&fixed_tm))
  ------------------
  |  Branch (2713:9): [True: 0, False: 13]
  ------------------
 2714|      0|        return 0;
 2715|       |
 2716|     13|    return (((uint32_t)fixed_tm.tm_mday + (32 * ((uint32_t)fixed_tm.tm_mon + 1)) + (512 * (uint32_t)fixed_tm.tm_year)) << 16) |
 2717|     13|        (((uint32_t)fixed_tm.tm_sec / 2) + (32 * (uint32_t)fixed_tm.tm_min) + (2048 * (uint32_t)fixed_tm.tm_hour));
 2718|     13|}
mz_zip.c:mz_zip_write_cd:
 1098|    210|static int32_t mz_zip_write_cd(void *handle) {
 1099|    210|    mz_zip *zip = (mz_zip *)handle;
 1100|    210|    int64_t zip64_eocd_pos_inzip = 0;
 1101|    210|    int64_t disk_number = 0;
 1102|    210|    int64_t disk_size = 0;
 1103|    210|    int32_t comment_size = 0;
 1104|    210|    int32_t err = MZ_OK;
  ------------------
  |  |   21|    210|#define MZ_OK                           (0)  /* zlib */
  ------------------
 1105|       |
 1106|    210|    if (!zip)
  ------------------
  |  Branch (1106:9): [True: 0, False: 210]
  ------------------
 1107|      0|        return MZ_PARAM_ERROR;
  ------------------
  |  |   31|      0|#define MZ_PARAM_ERROR                  (-102)
  ------------------
 1108|       |
 1109|    210|    if (mz_stream_get_prop_int64(zip->stream, MZ_STREAM_PROP_DISK_NUMBER, &disk_number) == MZ_OK)
  ------------------
  |  |   27|    210|#define MZ_STREAM_PROP_DISK_NUMBER          (8)
  ------------------
                  if (mz_stream_get_prop_int64(zip->stream, MZ_STREAM_PROP_DISK_NUMBER, &disk_number) == MZ_OK)
  ------------------
  |  |   21|    210|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (1109:9): [True: 0, False: 210]
  ------------------
 1110|      0|        zip->disk_number_with_cd = (uint32_t)disk_number;
 1111|    210|    if (mz_stream_get_prop_int64(zip->stream, MZ_STREAM_PROP_DISK_SIZE, &disk_size) == MZ_OK && disk_size > 0)
  ------------------
  |  |   26|    210|#define MZ_STREAM_PROP_DISK_SIZE            (7)
  ------------------
                  if (mz_stream_get_prop_int64(zip->stream, MZ_STREAM_PROP_DISK_SIZE, &disk_size) == MZ_OK && disk_size > 0)
  ------------------
  |  |   21|    420|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (1111:9): [True: 0, False: 210]
  |  Branch (1111:97): [True: 0, False: 0]
  ------------------
 1112|      0|        zip->disk_number_with_cd += 1;
 1113|    210|    mz_stream_set_prop_int64(zip->stream, MZ_STREAM_PROP_DISK_NUMBER, -1);
  ------------------
  |  |   27|    210|#define MZ_STREAM_PROP_DISK_NUMBER          (8)
  ------------------
 1114|    210|    if ((zip->disk_number_with_cd > 0) && (zip->open_mode & MZ_OPEN_MODE_APPEND)) {
  ------------------
  |  |   53|      0|#define MZ_OPEN_MODE_APPEND             (0x04)
  ------------------
  |  Branch (1114:9): [True: 0, False: 210]
  |  Branch (1114:43): [True: 0, False: 0]
  ------------------
 1115|       |        // Overwrite existing central directory if using split disks
 1116|      0|        mz_stream_seek(zip->stream, 0, MZ_SEEK_SET);
  ------------------
  |  |   58|      0|#define MZ_SEEK_SET                     (0)
  ------------------
 1117|      0|    }
 1118|       |
 1119|    210|    zip->cd_offset = mz_stream_tell(zip->stream);
 1120|    210|    mz_stream_seek(zip->cd_mem_stream, 0, MZ_SEEK_END);
  ------------------
  |  |   60|    210|#define MZ_SEEK_END                     (2)
  ------------------
 1121|    210|    zip->cd_size = (uint32_t)mz_stream_tell(zip->cd_mem_stream);
 1122|    210|    mz_stream_seek(zip->cd_mem_stream, 0, MZ_SEEK_SET);
  ------------------
  |  |   58|    210|#define MZ_SEEK_SET                     (0)
  ------------------
 1123|       |
 1124|    210|    err = mz_stream_copy(zip->stream, zip->cd_mem_stream, (int32_t)zip->cd_size);
 1125|       |
 1126|    210|    mz_zip_print("Zip - Write cd (disk %" PRId32 " entries %" PRId64 " offset %" PRId64 " size %" PRId64 ")\n",
 1127|    210|        zip->disk_number_with_cd, zip->number_entry, zip->cd_offset, zip->cd_size);
 1128|       |
 1129|    210|    if (zip->cd_size == 0 && zip->number_entry > 0) {
  ------------------
  |  Branch (1129:9): [True: 210, False: 0]
  |  Branch (1129:30): [True: 0, False: 210]
  ------------------
 1130|       |        // Zip does not contain central directory, open with recovery option
 1131|      0|        return MZ_FORMAT_ERROR;
  ------------------
  |  |   32|      0|#define MZ_FORMAT_ERROR                 (-103)
  ------------------
 1132|      0|    }
 1133|       |
 1134|       |    /* Write the ZIP64 central directory header */
 1135|    210|    if (zip->cd_offset >= UINT32_MAX || zip->number_entry >= UINT16_MAX) {
  ------------------
  |  Branch (1135:9): [True: 0, False: 210]
  |  Branch (1135:41): [True: 0, False: 210]
  ------------------
 1136|      0|        zip64_eocd_pos_inzip = mz_stream_tell(zip->stream);
 1137|       |
 1138|      0|        err = mz_stream_write_uint32(zip->stream, MZ_ZIP_MAGIC_ENDHEADER64);
  ------------------
  |  |   64|      0|#define MZ_ZIP_MAGIC_ENDHEADER64        (0x06064b50)
  ------------------
 1139|       |
 1140|       |        /* Size of this 'zip64 end of central directory' */
 1141|      0|        if (err == MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (1141:13): [True: 0, False: 0]
  ------------------
 1142|      0|            err = mz_stream_write_uint64(zip->stream, (uint64_t)44);
 1143|       |        /* Version made by */
 1144|      0|        if (err == MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (1144:13): [True: 0, False: 0]
  ------------------
 1145|      0|            err = mz_stream_write_uint16(zip->stream, zip->version_madeby);
 1146|       |        /* Version needed */
 1147|      0|        if (err == MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (1147:13): [True: 0, False: 0]
  ------------------
 1148|      0|            err = mz_stream_write_uint16(zip->stream, (uint16_t)45);
 1149|       |        /* Number of this disk */
 1150|      0|        if (err == MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (1150:13): [True: 0, False: 0]
  ------------------
 1151|      0|            err = mz_stream_write_uint32(zip->stream, zip->disk_number_with_cd);
 1152|       |        /* Number of the disk with the start of the central directory */
 1153|      0|        if (err == MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (1153:13): [True: 0, False: 0]
  ------------------
 1154|      0|            err = mz_stream_write_uint32(zip->stream, zip->disk_number_with_cd);
 1155|       |        /* Total number of entries in the central dir on this disk */
 1156|      0|        if (err == MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (1156:13): [True: 0, False: 0]
  ------------------
 1157|      0|            err = mz_stream_write_uint64(zip->stream, zip->number_entry);
 1158|       |        /* Total number of entries in the central dir */
 1159|      0|        if (err == MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (1159:13): [True: 0, False: 0]
  ------------------
 1160|      0|            err = mz_stream_write_uint64(zip->stream, zip->number_entry);
 1161|       |        /* Size of the central directory */
 1162|      0|        if (err == MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (1162:13): [True: 0, False: 0]
  ------------------
 1163|      0|            err = mz_stream_write_int64(zip->stream, zip->cd_size);
 1164|       |        /* Offset of start of central directory with respect to the starting disk number */
 1165|      0|        if (err == MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (1165:13): [True: 0, False: 0]
  ------------------
 1166|      0|            err = mz_stream_write_int64(zip->stream, zip->cd_offset);
 1167|      0|        if (err == MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (1167:13): [True: 0, False: 0]
  ------------------
 1168|      0|            err = mz_stream_write_uint32(zip->stream, MZ_ZIP_MAGIC_ENDLOCHEADER64);
  ------------------
  |  |   65|      0|#define MZ_ZIP_MAGIC_ENDLOCHEADER64     (0x07064b50)
  ------------------
 1169|       |
 1170|       |        /* Number of the disk with the start of the central directory */
 1171|      0|        if (err == MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (1171:13): [True: 0, False: 0]
  ------------------
 1172|      0|            err = mz_stream_write_uint32(zip->stream, zip->disk_number_with_cd);
 1173|       |        /* Relative offset to the end of zip64 central directory */
 1174|      0|        if (err == MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (1174:13): [True: 0, False: 0]
  ------------------
 1175|      0|            err = mz_stream_write_int64(zip->stream, zip64_eocd_pos_inzip);
 1176|       |        /* Number of the disk with the start of the central directory */
 1177|      0|        if (err == MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (1177:13): [True: 0, False: 0]
  ------------------
 1178|      0|            err = mz_stream_write_uint32(zip->stream, zip->disk_number_with_cd + 1);
 1179|      0|    }
 1180|       |
 1181|       |    /* Write the central directory header */
 1182|       |
 1183|       |    /* Signature */
 1184|    210|    if (err == MZ_OK)
  ------------------
  |  |   21|    210|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (1184:9): [True: 210, False: 0]
  ------------------
 1185|    210|        err = mz_stream_write_uint32(zip->stream, MZ_ZIP_MAGIC_ENDHEADER);
  ------------------
  |  |   62|    210|#define MZ_ZIP_MAGIC_ENDHEADER          (0x06054b50)
  ------------------
 1186|       |    /* Number of this disk */
 1187|    210|    if (err == MZ_OK)
  ------------------
  |  |   21|    210|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (1187:9): [True: 0, False: 210]
  ------------------
 1188|      0|        err = mz_stream_write_uint16(zip->stream, (uint16_t)zip->disk_number_with_cd);
 1189|       |    /* Number of the disk with the start of the central directory */
 1190|    210|    if (err == MZ_OK)
  ------------------
  |  |   21|    210|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (1190:9): [True: 0, False: 210]
  ------------------
 1191|      0|        err = mz_stream_write_uint16(zip->stream, (uint16_t)zip->disk_number_with_cd);
 1192|       |    /* Total number of entries in the central dir on this disk */
 1193|    210|    if (err == MZ_OK) {
  ------------------
  |  |   21|    210|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (1193:9): [True: 0, False: 210]
  ------------------
 1194|      0|        if (zip->number_entry >= UINT16_MAX)
  ------------------
  |  Branch (1194:13): [True: 0, False: 0]
  ------------------
 1195|      0|            err = mz_stream_write_uint16(zip->stream, UINT16_MAX);
 1196|      0|        else
 1197|      0|            err = mz_stream_write_uint16(zip->stream, (uint16_t)zip->number_entry);
 1198|      0|    }
 1199|       |    /* Total number of entries in the central dir */
 1200|    210|    if (err == MZ_OK) {
  ------------------
  |  |   21|    210|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (1200:9): [True: 0, False: 210]
  ------------------
 1201|      0|        if (zip->number_entry >= UINT16_MAX)
  ------------------
  |  Branch (1201:13): [True: 0, False: 0]
  ------------------
 1202|      0|            err = mz_stream_write_uint16(zip->stream, UINT16_MAX);
 1203|      0|        else
 1204|      0|            err = mz_stream_write_uint16(zip->stream, (uint16_t)zip->number_entry);
 1205|      0|    }
 1206|       |    /* Size of the central directory */
 1207|    210|    if (err == MZ_OK)
  ------------------
  |  |   21|    210|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (1207:9): [True: 0, False: 210]
  ------------------
 1208|      0|        err = mz_stream_write_uint32(zip->stream, (uint32_t)zip->cd_size);
 1209|       |    /* Offset of start of central directory with respect to the starting disk number */
 1210|    210|    if (err == MZ_OK) {
  ------------------
  |  |   21|    210|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (1210:9): [True: 0, False: 210]
  ------------------
 1211|      0|        if (zip->cd_offset >= UINT32_MAX)
  ------------------
  |  Branch (1211:13): [True: 0, False: 0]
  ------------------
 1212|      0|            err = mz_stream_write_uint32(zip->stream, UINT32_MAX);
 1213|      0|        else
 1214|      0|            err = mz_stream_write_uint32(zip->stream, (uint32_t)zip->cd_offset);
 1215|      0|    }
 1216|       |
 1217|       |    /* Write global comment */
 1218|    210|    if (zip->comment) {
  ------------------
  |  Branch (1218:9): [True: 0, False: 210]
  ------------------
 1219|      0|        comment_size = (int32_t)strlen(zip->comment);
 1220|      0|        if (comment_size > UINT16_MAX)
  ------------------
  |  Branch (1220:13): [True: 0, False: 0]
  ------------------
 1221|      0|            comment_size = UINT16_MAX;
 1222|      0|    }
 1223|    210|    if (err == MZ_OK)
  ------------------
  |  |   21|    210|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (1223:9): [True: 0, False: 210]
  ------------------
 1224|      0|        err = mz_stream_write_uint16(zip->stream, (uint16_t)comment_size);
 1225|    210|    if (err == MZ_OK) {
  ------------------
  |  |   21|    210|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (1225:9): [True: 0, False: 210]
  ------------------
 1226|      0|        if (mz_stream_write(zip->stream, zip->comment, comment_size) != comment_size)
  ------------------
  |  Branch (1226:13): [True: 0, False: 0]
  ------------------
 1227|      0|            err = MZ_READ_ERROR;
  ------------------
  |  |   44|      0|#define MZ_READ_ERROR                   (-115)
  ------------------
 1228|      0|    }
 1229|    210|    return err;
 1230|    210|}
mz_zip.c:mz_zip_get_pk_verify:
  192|     13|{
  193|       |    /* Info-ZIP modification to ZipCrypto format: if bit 3 of the general
  194|       |     * purpose bit flag is set, it uses high byte of 16-bit File Time. */
  195|     13|    if (flag & MZ_ZIP_FLAG_DATA_DESCRIPTOR)
  ------------------
  |  |   84|     13|#define MZ_ZIP_FLAG_DATA_DESCRIPTOR     (1 << 3)
  ------------------
  |  Branch (195:9): [True: 13, False: 0]
  ------------------
  196|     13|        return ((dos_date >> 16) & 0xff) << 8 | ((dos_date >> 8) & 0xff);
  197|      0|    return ((crc >> 16) & 0xff) << 8 | ((crc >> 24) & 0xff);
  198|     13|}
mz_zip.c:mz_zip_entry_write_header:
  596|     85|static int32_t mz_zip_entry_write_header(void *stream, uint8_t local, mz_zip_file *file_info) {
  597|     85|    uint64_t ntfs_time = 0;
  598|     85|    uint32_t reserved = 0;
  599|     85|    uint32_t dos_date = 0;
  600|     85|    uint16_t extrafield_size = 0;
  601|     85|    uint16_t field_type = 0;
  602|     85|    uint16_t field_length = 0;
  603|     85|    uint16_t field_length_zip64 = 0;
  604|     85|    uint16_t field_length_ntfs = 0;
  605|     85|    uint16_t field_length_aes = 0;
  606|     85|    uint16_t field_length_unix1 = 0;
  607|     85|    uint16_t filename_size = 0;
  608|     85|    uint16_t filename_length = 0;
  609|     85|    uint16_t linkname_size = 0;
  610|     85|    uint16_t version_needed = 0;
  611|     85|    int32_t comment_size = 0;
  612|     85|    int32_t err = MZ_OK;
  ------------------
  |  |   21|     85|#define MZ_OK                           (0)  /* zlib */
  ------------------
  613|     85|    int32_t err_mem = MZ_OK;
  ------------------
  |  |   21|     85|#define MZ_OK                           (0)  /* zlib */
  ------------------
  614|     85|    uint8_t zip64 = 0;
  615|     85|    uint8_t skip_aes = 0;
  616|     85|    uint8_t mask = 0;
  617|     85|    uint8_t write_end_slash = 0;
  618|     85|    const char *filename = NULL;
  619|     85|    char masked_name[64];
  620|     85|    void *file_extra_stream = NULL;
  621|       |
  622|     85|    if (!file_info)
  ------------------
  |  Branch (622:9): [True: 0, False: 85]
  ------------------
  623|      0|        return MZ_PARAM_ERROR;
  ------------------
  |  |   31|      0|#define MZ_PARAM_ERROR                  (-102)
  ------------------
  624|       |
  625|     85|    if ((local) && (file_info->flag & MZ_ZIP_FLAG_MASK_LOCAL_INFO))
  ------------------
  |  |   86|     85|#define MZ_ZIP_FLAG_MASK_LOCAL_INFO     (1 << 13)
  ------------------
  |  Branch (625:9): [True: 85, False: 0]
  |  Branch (625:20): [True: 4, False: 81]
  ------------------
  626|      4|        mask = 1;
  627|       |
  628|       |    /* Determine if zip64 extra field is necessary */
  629|     85|    err = mz_zip_entry_needs_zip64(file_info, local, &zip64);
  630|     85|    if (err != MZ_OK)
  ------------------
  |  |   21|     85|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (630:9): [True: 0, False: 85]
  ------------------
  631|      0|        return err;
  632|       |
  633|       |    /* Start calculating extra field sizes */
  634|     85|    if (zip64) {
  ------------------
  |  Branch (634:9): [True: 53, False: 32]
  ------------------
  635|       |        /* Both compressed and uncompressed sizes must be included (at least in local header) */
  636|     53|        field_length_zip64 = 8 + 8;
  637|     53|        if ((!local) && (file_info->disk_offset >= UINT32_MAX))
  ------------------
  |  Branch (637:13): [True: 0, False: 53]
  |  Branch (637:25): [True: 0, False: 0]
  ------------------
  638|      0|            field_length_zip64 += 8;
  639|       |
  640|     53|        extrafield_size += 4;
  641|     53|        extrafield_size += field_length_zip64;
  642|     53|    }
  643|       |
  644|       |    /* Calculate extra field size and check for duplicates */
  645|     85|    if (file_info->extrafield_size > 0) {
  ------------------
  |  Branch (645:9): [True: 0, False: 85]
  ------------------
  646|      0|        mz_stream_mem_create(&file_extra_stream);
  647|      0|        mz_stream_mem_set_buffer(file_extra_stream, (void *)file_info->extrafield,
  648|      0|            file_info->extrafield_size);
  649|       |
  650|      0|        do {
  651|      0|            err_mem = mz_stream_read_uint16(file_extra_stream, &field_type);
  652|      0|            if (err_mem == MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (652:17): [True: 0, False: 0]
  ------------------
  653|      0|                err_mem = mz_stream_read_uint16(file_extra_stream, &field_length);
  654|      0|            if (err_mem != MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (654:17): [True: 0, False: 0]
  ------------------
  655|      0|                break;
  656|       |
  657|       |            /* Prefer incoming aes extensions over ours */
  658|      0|            if (field_type == MZ_ZIP_EXTENSION_AES)
  ------------------
  |  |   91|      0|#define MZ_ZIP_EXTENSION_AES            (0x9901)
  ------------------
  |  Branch (658:17): [True: 0, False: 0]
  ------------------
  659|      0|                skip_aes = 1;
  660|       |
  661|       |            /* Prefer our zip64, ntfs, unix1 extension over incoming */
  662|      0|            if (field_type != MZ_ZIP_EXTENSION_ZIP64 && field_type != MZ_ZIP_EXTENSION_NTFS &&
  ------------------
  |  |   89|      0|#define MZ_ZIP_EXTENSION_ZIP64          (0x0001)
  ------------------
                          if (field_type != MZ_ZIP_EXTENSION_ZIP64 && field_type != MZ_ZIP_EXTENSION_NTFS &&
  ------------------
  |  |   90|      0|#define MZ_ZIP_EXTENSION_NTFS           (0x000a)
  ------------------
  |  Branch (662:17): [True: 0, False: 0]
  |  Branch (662:57): [True: 0, False: 0]
  ------------------
  663|      0|                field_type != MZ_ZIP_EXTENSION_UNIX1)
  ------------------
  |  |   92|      0|#define MZ_ZIP_EXTENSION_UNIX1          (0x000d)
  ------------------
  |  Branch (663:17): [True: 0, False: 0]
  ------------------
  664|      0|                extrafield_size += 4 + field_length;
  665|       |
  666|      0|            if (err_mem == MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (666:17): [True: 0, False: 0]
  ------------------
  667|      0|                err_mem = mz_stream_seek(file_extra_stream, field_length, MZ_SEEK_CUR);
  ------------------
  |  |   59|      0|#define MZ_SEEK_CUR                     (1)
  ------------------
  668|      0|        } while (err_mem == MZ_OK);
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (668:18): [True: 0, False: 0]
  ------------------
  669|      0|    }
  670|       |
  671|      0|#ifdef HAVE_WZAES
  672|     85|    if (!skip_aes) {
  ------------------
  |  Branch (672:9): [True: 85, False: 0]
  ------------------
  673|     85|        if ((file_info->flag & MZ_ZIP_FLAG_ENCRYPTED) && (file_info->aes_version)) {
  ------------------
  |  |   77|     85|#define MZ_ZIP_FLAG_ENCRYPTED           (1 << 0)
  ------------------
  |  Branch (673:13): [True: 5, False: 80]
  |  Branch (673:58): [True: 0, False: 5]
  ------------------
  674|      0|            field_length_aes = 1 + 1 + 1 + 2 + 2;
  675|      0|            extrafield_size += 4 + field_length_aes;
  676|      0|        }
  677|     85|    }
  678|       |#else
  679|       |    MZ_UNUSED(field_length_aes);
  680|       |    MZ_UNUSED(skip_aes);
  681|       |#endif
  682|       |    /* NTFS timestamps */
  683|     85|    if ((file_info->modified_date != 0) &&
  ------------------
  |  Branch (683:9): [True: 0, False: 85]
  ------------------
  684|     85|        (file_info->accessed_date != 0) &&
  ------------------
  |  Branch (684:9): [True: 0, False: 0]
  ------------------
  685|     85|        (file_info->creation_date != 0) && (!mask)) {
  ------------------
  |  Branch (685:9): [True: 0, False: 0]
  |  Branch (685:44): [True: 0, False: 0]
  ------------------
  686|      0|        field_length_ntfs = 8 + 8 + 8 + 4 + 2 + 2;
  687|      0|        extrafield_size += 4 + field_length_ntfs;
  688|      0|    }
  689|       |
  690|       |    /* Unix1 symbolic links */
  691|     85|    if (file_info->linkname && *file_info->linkname != 0) {
  ------------------
  |  Branch (691:9): [True: 85, False: 0]
  |  Branch (691:32): [True: 0, False: 85]
  ------------------
  692|      0|        linkname_size = (uint16_t)strlen(file_info->linkname);
  693|      0|        field_length_unix1 = 12 + linkname_size;
  694|      0|        extrafield_size += 4 + field_length_unix1;
  695|      0|    }
  696|       |
  697|     85|    if (local)
  ------------------
  |  Branch (697:9): [True: 85, False: 0]
  ------------------
  698|     85|        err = mz_stream_write_uint32(stream, MZ_ZIP_MAGIC_LOCALHEADER);
  ------------------
  |  |   58|     85|#define MZ_ZIP_MAGIC_LOCALHEADER        (0x04034b50)
  ------------------
  699|      0|    else {
  700|      0|        err = mz_stream_write_uint32(stream, MZ_ZIP_MAGIC_CENTRALHEADER);
  ------------------
  |  |   60|      0|#define MZ_ZIP_MAGIC_CENTRALHEADER      (0x02014b50)
  ------------------
  701|      0|        if (err == MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (701:13): [True: 0, False: 0]
  ------------------
  702|      0|            err = mz_stream_write_uint16(stream, file_info->version_madeby);
  703|      0|    }
  704|       |
  705|       |    /* Calculate version needed to extract */
  706|     85|    if (err == MZ_OK) {
  ------------------
  |  |   21|     85|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (706:9): [True: 0, False: 85]
  ------------------
  707|      0|        version_needed = file_info->version_needed;
  708|      0|        if (version_needed == 0) {
  ------------------
  |  Branch (708:13): [True: 0, False: 0]
  ------------------
  709|      0|            version_needed = 20;
  710|      0|            if (zip64)
  ------------------
  |  Branch (710:17): [True: 0, False: 0]
  ------------------
  711|      0|                version_needed = 45;
  712|      0|#ifdef HAVE_WZAES
  713|      0|            if ((file_info->flag & MZ_ZIP_FLAG_ENCRYPTED) && (file_info->aes_version))
  ------------------
  |  |   77|      0|#define MZ_ZIP_FLAG_ENCRYPTED           (1 << 0)
  ------------------
  |  Branch (713:17): [True: 0, False: 0]
  |  Branch (713:62): [True: 0, False: 0]
  ------------------
  714|      0|                version_needed = 51;
  715|      0|#endif
  716|       |#if defined(HAVE_LZMA) || defined(HAVE_LIBCOMP)
  717|       |            if ((file_info->compression_method == MZ_COMPRESS_METHOD_LZMA) ||
  718|       |                (file_info->compression_method == MZ_COMPRESS_METHOD_XZ))
  719|       |                version_needed = 63;
  720|       |#endif
  721|      0|        }
  722|      0|        err = mz_stream_write_uint16(stream, version_needed);
  723|      0|    }
  724|     85|    if (err == MZ_OK)
  ------------------
  |  |   21|     85|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (724:9): [True: 0, False: 85]
  ------------------
  725|      0|        err = mz_stream_write_uint16(stream, file_info->flag);
  726|     85|    if (err == MZ_OK) {
  ------------------
  |  |   21|     85|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (726:9): [True: 0, False: 85]
  ------------------
  727|      0|#ifdef HAVE_WZAES
  728|      0|        if ((file_info->flag & MZ_ZIP_FLAG_ENCRYPTED) && (file_info->aes_version))
  ------------------
  |  |   77|      0|#define MZ_ZIP_FLAG_ENCRYPTED           (1 << 0)
  ------------------
  |  Branch (728:13): [True: 0, False: 0]
  |  Branch (728:58): [True: 0, False: 0]
  ------------------
  729|      0|            err = mz_stream_write_uint16(stream, MZ_COMPRESS_METHOD_AES);
  ------------------
  |  |   69|      0|#define MZ_COMPRESS_METHOD_AES          (99)
  ------------------
  730|      0|        else
  731|      0|#endif
  732|      0|            err = mz_stream_write_uint16(stream, file_info->compression_method);
  733|      0|    }
  734|     85|    if (err == MZ_OK) {
  ------------------
  |  |   21|     85|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (734:9): [True: 0, False: 85]
  ------------------
  735|      0|        if (file_info->modified_date != 0 && !mask)
  ------------------
  |  Branch (735:13): [True: 0, False: 0]
  |  Branch (735:46): [True: 0, False: 0]
  ------------------
  736|      0|            dos_date = mz_zip_time_t_to_dos_date(file_info->modified_date);
  737|      0|        err = mz_stream_write_uint32(stream, dos_date);
  738|      0|    }
  739|       |
  740|     85|    if (err == MZ_OK)
  ------------------
  |  |   21|     85|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (740:9): [True: 0, False: 85]
  ------------------
  741|      0|        err = mz_zip_entry_write_crc_sizes(stream, zip64, mask, file_info);
  742|       |
  743|     85|    if (mask) {
  ------------------
  |  Branch (743:9): [True: 4, False: 81]
  ------------------
  744|      4|        snprintf(masked_name, sizeof(masked_name), "%" PRIx32 "_%" PRIx64,
  745|      4|            file_info->disk_number, file_info->disk_offset);
  746|      4|        filename = masked_name;
  747|     81|    } else {
  748|     81|        filename = file_info->filename;
  749|     81|    }
  750|       |
  751|     85|    filename_length = (uint16_t)strlen(filename);
  752|     85|    filename_size += filename_length;
  753|       |
  754|     85|    if ((mz_zip_attrib_is_dir(file_info->external_fa, file_info->version_madeby) == MZ_OK) &&
  ------------------
  |  |   21|     85|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (754:9): [True: 0, False: 85]
  ------------------
  755|     85|        ((filename[filename_length - 1] != '/') && (filename[filename_length - 1] != '\\'))) {
  ------------------
  |  Branch (755:10): [True: 0, False: 0]
  |  Branch (755:52): [True: 0, False: 0]
  ------------------
  756|      0|        filename_size += 1;
  757|      0|        write_end_slash = 1;
  758|      0|    }
  759|       |
  760|     85|    if (err == MZ_OK)
  ------------------
  |  |   21|     85|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (760:9): [True: 0, False: 85]
  ------------------
  761|      0|        err = mz_stream_write_uint16(stream, filename_size);
  762|     85|    if (err == MZ_OK)
  ------------------
  |  |   21|     85|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (762:9): [True: 0, False: 85]
  ------------------
  763|      0|        err = mz_stream_write_uint16(stream, extrafield_size);
  764|       |
  765|     85|    if (!local) {
  ------------------
  |  Branch (765:9): [True: 0, False: 85]
  ------------------
  766|      0|        if (file_info->comment) {
  ------------------
  |  Branch (766:13): [True: 0, False: 0]
  ------------------
  767|      0|            comment_size = (int32_t)strlen(file_info->comment);
  768|      0|            if (comment_size > UINT16_MAX)
  ------------------
  |  Branch (768:17): [True: 0, False: 0]
  ------------------
  769|      0|                comment_size = UINT16_MAX;
  770|      0|        }
  771|      0|        if (err == MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (771:13): [True: 0, False: 0]
  ------------------
  772|      0|            err = mz_stream_write_uint16(stream, (uint16_t)comment_size);
  773|      0|        if (err == MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (773:13): [True: 0, False: 0]
  ------------------
  774|      0|            err = mz_stream_write_uint16(stream, (uint16_t)file_info->disk_number);
  775|      0|        if (err == MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (775:13): [True: 0, False: 0]
  ------------------
  776|      0|            err = mz_stream_write_uint16(stream, file_info->internal_fa);
  777|      0|        if (err == MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (777:13): [True: 0, False: 0]
  ------------------
  778|      0|            err = mz_stream_write_uint32(stream, file_info->external_fa);
  779|      0|        if (err == MZ_OK) {
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (779:13): [True: 0, False: 0]
  ------------------
  780|      0|            if (file_info->disk_offset >= UINT32_MAX)
  ------------------
  |  Branch (780:17): [True: 0, False: 0]
  ------------------
  781|      0|                err = mz_stream_write_uint32(stream, UINT32_MAX);
  782|      0|            else
  783|      0|                err = mz_stream_write_uint32(stream, (uint32_t)file_info->disk_offset);
  784|      0|        }
  785|      0|    }
  786|       |
  787|     85|    if (err == MZ_OK) {
  ------------------
  |  |   21|     85|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (787:9): [True: 0, False: 85]
  ------------------
  788|      0|        const char *backslash = NULL;
  789|      0|        const char *next = filename;
  790|      0|        int32_t left = filename_length;
  791|       |
  792|       |        /* Ensure all slashes are written as forward slashes according to 4.4.17.1 */
  793|      0|        while ((err == MZ_OK) && (backslash = strrchr(next, '\\'))) {
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (793:16): [True: 0, False: 0]
  |  Branch (793:34): [True: 0, False: 0]
  ------------------
  794|      0|            int32_t part_length = (int32_t)(backslash - next);
  795|       |
  796|      0|            if (mz_stream_write(stream, next, part_length) != part_length ||
  ------------------
  |  Branch (796:17): [True: 0, False: 0]
  ------------------
  797|      0|                mz_stream_write(stream, "/", 1) != 1)
  ------------------
  |  Branch (797:17): [True: 0, False: 0]
  ------------------
  798|      0|                err = MZ_WRITE_ERROR;
  ------------------
  |  |   45|      0|#define MZ_WRITE_ERROR                  (-116)
  ------------------
  799|       |
  800|      0|            left -= part_length + 1;
  801|      0|            next = backslash + 1;
  802|      0|        }
  803|       |
  804|      0|        if (err == MZ_OK && left > 0) {
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (804:13): [True: 0, False: 0]
  |  Branch (804:29): [True: 0, False: 0]
  ------------------
  805|      0|            if (mz_stream_write(stream, next, left) != left)
  ------------------
  |  Branch (805:17): [True: 0, False: 0]
  ------------------
  806|      0|                err = MZ_WRITE_ERROR;
  ------------------
  |  |   45|      0|#define MZ_WRITE_ERROR                  (-116)
  ------------------
  807|      0|        }
  808|       |
  809|       |        /* Ensure that directories have a slash appended to them for compatibility */
  810|      0|        if (err == MZ_OK && write_end_slash)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (810:13): [True: 0, False: 0]
  |  Branch (810:29): [True: 0, False: 0]
  ------------------
  811|      0|            err = mz_stream_write_uint8(stream, '/');
  812|      0|    }
  813|       |
  814|       |    /* Write ZIP64 extra field first so we can update sizes later if data descriptor not used */
  815|     85|    if ((err == MZ_OK) && (zip64)) {
  ------------------
  |  |   21|     85|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (815:9): [True: 0, False: 85]
  |  Branch (815:27): [True: 0, False: 0]
  ------------------
  816|      0|        err = mz_zip_extrafield_write(stream, MZ_ZIP_EXTENSION_ZIP64, field_length_zip64);
  ------------------
  |  |   89|      0|#define MZ_ZIP_EXTENSION_ZIP64          (0x0001)
  ------------------
  817|      0|        if (err == MZ_OK) {
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (817:13): [True: 0, False: 0]
  ------------------
  818|      0|            if (mask)
  ------------------
  |  Branch (818:17): [True: 0, False: 0]
  ------------------
  819|      0|                err = mz_stream_write_int64(stream, 0);
  820|      0|            else
  821|      0|                err = mz_stream_write_int64(stream, file_info->uncompressed_size);
  822|      0|        }
  823|      0|        if (err == MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (823:13): [True: 0, False: 0]
  ------------------
  824|      0|            err = mz_stream_write_int64(stream, file_info->compressed_size);
  825|      0|        if ((err == MZ_OK) && (!local) && (file_info->disk_offset >= UINT32_MAX))
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (825:13): [True: 0, False: 0]
  |  Branch (825:31): [True: 0, False: 0]
  |  Branch (825:43): [True: 0, False: 0]
  ------------------
  826|      0|            err = mz_stream_write_int64(stream, file_info->disk_offset);
  827|      0|        if ((err == MZ_OK) && (!local) && (file_info->disk_number >= UINT16_MAX))
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (827:13): [True: 0, False: 0]
  |  Branch (827:31): [True: 0, False: 0]
  |  Branch (827:43): [True: 0, False: 0]
  ------------------
  828|      0|            err = mz_stream_write_uint32(stream, file_info->disk_number);
  829|      0|    }
  830|       |    /* Write NTFS extra field */
  831|     85|    if ((err == MZ_OK) && (field_length_ntfs > 0)) {
  ------------------
  |  |   21|     85|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (831:9): [True: 0, False: 85]
  |  Branch (831:27): [True: 0, False: 0]
  ------------------
  832|      0|        err = mz_zip_extrafield_write(stream, MZ_ZIP_EXTENSION_NTFS, field_length_ntfs);
  ------------------
  |  |   90|      0|#define MZ_ZIP_EXTENSION_NTFS           (0x000a)
  ------------------
  833|      0|        if (err == MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (833:13): [True: 0, False: 0]
  ------------------
  834|      0|            err = mz_stream_write_uint32(stream, reserved);
  835|      0|        if (err == MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (835:13): [True: 0, False: 0]
  ------------------
  836|      0|            err = mz_stream_write_uint16(stream, 0x01);
  837|      0|        if (err == MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (837:13): [True: 0, False: 0]
  ------------------
  838|      0|            err = mz_stream_write_uint16(stream, field_length_ntfs - 8);
  839|      0|        if (err == MZ_OK) {
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (839:13): [True: 0, False: 0]
  ------------------
  840|      0|            mz_zip_unix_to_ntfs_time(file_info->modified_date, &ntfs_time);
  841|      0|            err = mz_stream_write_uint64(stream, ntfs_time);
  842|      0|        }
  843|      0|        if (err == MZ_OK) {
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (843:13): [True: 0, False: 0]
  ------------------
  844|      0|            mz_zip_unix_to_ntfs_time(file_info->accessed_date, &ntfs_time);
  845|      0|            err = mz_stream_write_uint64(stream, ntfs_time);
  846|      0|        }
  847|      0|        if (err == MZ_OK) {
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (847:13): [True: 0, False: 0]
  ------------------
  848|      0|            mz_zip_unix_to_ntfs_time(file_info->creation_date, &ntfs_time);
  849|      0|            err = mz_stream_write_uint64(stream, ntfs_time);
  850|      0|        }
  851|      0|    }
  852|       |    /* Write UNIX extra block extra field */
  853|     85|    if ((err == MZ_OK) && (field_length_unix1 > 0)) {
  ------------------
  |  |   21|     85|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (853:9): [True: 0, False: 85]
  |  Branch (853:27): [True: 0, False: 0]
  ------------------
  854|      0|        err = mz_zip_extrafield_write(stream, MZ_ZIP_EXTENSION_UNIX1, field_length_unix1);
  ------------------
  |  |   92|      0|#define MZ_ZIP_EXTENSION_UNIX1          (0x000d)
  ------------------
  855|      0|        if (err == MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (855:13): [True: 0, False: 0]
  ------------------
  856|      0|            err = mz_stream_write_uint32(stream, (uint32_t)file_info->accessed_date);
  857|      0|        if (err == MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (857:13): [True: 0, False: 0]
  ------------------
  858|      0|            err = mz_stream_write_uint32(stream, (uint32_t)file_info->modified_date);
  859|      0|        if (err == MZ_OK) /* User id */
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (859:13): [True: 0, False: 0]
  ------------------
  860|      0|            err = mz_stream_write_uint16(stream, 0);
  861|      0|        if (err == MZ_OK) /* Group id */
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (861:13): [True: 0, False: 0]
  ------------------
  862|      0|            err = mz_stream_write_uint16(stream, 0);
  863|      0|        if (err == MZ_OK && linkname_size > 0) {
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (863:13): [True: 0, False: 0]
  |  Branch (863:29): [True: 0, False: 0]
  ------------------
  864|      0|            if (mz_stream_write(stream, file_info->linkname, linkname_size) != linkname_size)
  ------------------
  |  Branch (864:17): [True: 0, False: 0]
  ------------------
  865|      0|                err = MZ_WRITE_ERROR;
  ------------------
  |  |   45|      0|#define MZ_WRITE_ERROR                  (-116)
  ------------------
  866|      0|        }
  867|      0|    }
  868|     85|#ifdef HAVE_WZAES
  869|       |    /* Write AES extra field */
  870|     85|    if ((err == MZ_OK) && (!skip_aes) && (file_info->flag & MZ_ZIP_FLAG_ENCRYPTED) && (file_info->aes_version)) {
  ------------------
  |  |   21|     85|#define MZ_OK                           (0)  /* zlib */
  ------------------
                  if ((err == MZ_OK) && (!skip_aes) && (file_info->flag & MZ_ZIP_FLAG_ENCRYPTED) && (file_info->aes_version)) {
  ------------------
  |  |   77|      0|#define MZ_ZIP_FLAG_ENCRYPTED           (1 << 0)
  ------------------
  |  Branch (870:9): [True: 0, False: 85]
  |  Branch (870:27): [True: 0, False: 0]
  |  Branch (870:42): [True: 0, False: 0]
  |  Branch (870:87): [True: 0, False: 0]
  ------------------
  871|      0|        err = mz_zip_extrafield_write(stream, MZ_ZIP_EXTENSION_AES, field_length_aes);
  ------------------
  |  |   91|      0|#define MZ_ZIP_EXTENSION_AES            (0x9901)
  ------------------
  872|      0|        if (err == MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (872:13): [True: 0, False: 0]
  ------------------
  873|      0|            err = mz_stream_write_uint16(stream, file_info->aes_version);
  874|      0|        if (err == MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (874:13): [True: 0, False: 0]
  ------------------
  875|      0|            err = mz_stream_write_uint8(stream, 'A');
  876|      0|        if (err == MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (876:13): [True: 0, False: 0]
  ------------------
  877|      0|            err = mz_stream_write_uint8(stream, 'E');
  878|      0|        if (err == MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (878:13): [True: 0, False: 0]
  ------------------
  879|      0|            err = mz_stream_write_uint8(stream, file_info->aes_encryption_mode);
  880|      0|        if (err == MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (880:13): [True: 0, False: 0]
  ------------------
  881|      0|            err = mz_stream_write_uint16(stream, file_info->compression_method);
  882|      0|    }
  883|     85|#endif
  884|       |
  885|     85|    if (file_info->extrafield_size > 0) {
  ------------------
  |  Branch (885:9): [True: 0, False: 85]
  ------------------
  886|      0|        err_mem = mz_stream_mem_seek(file_extra_stream, 0, MZ_SEEK_SET);
  ------------------
  |  |   58|      0|#define MZ_SEEK_SET                     (0)
  ------------------
  887|      0|        while (err == MZ_OK && err_mem == MZ_OK) {
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
                      while (err == MZ_OK && err_mem == MZ_OK) {
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (887:16): [True: 0, False: 0]
  |  Branch (887:32): [True: 0, False: 0]
  ------------------
  888|      0|            err_mem = mz_stream_read_uint16(file_extra_stream, &field_type);
  889|      0|            if (err_mem == MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (889:17): [True: 0, False: 0]
  ------------------
  890|      0|                err_mem = mz_stream_read_uint16(file_extra_stream, &field_length);
  891|      0|            if (err_mem != MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (891:17): [True: 0, False: 0]
  ------------------
  892|      0|                break;
  893|       |
  894|       |            /* Prefer our zip 64, ntfs, unix1 extensions over incoming */
  895|      0|            if (field_type == MZ_ZIP_EXTENSION_ZIP64 || field_type == MZ_ZIP_EXTENSION_NTFS ||
  ------------------
  |  |   89|      0|#define MZ_ZIP_EXTENSION_ZIP64          (0x0001)
  ------------------
                          if (field_type == MZ_ZIP_EXTENSION_ZIP64 || field_type == MZ_ZIP_EXTENSION_NTFS ||
  ------------------
  |  |   90|      0|#define MZ_ZIP_EXTENSION_NTFS           (0x000a)
  ------------------
  |  Branch (895:17): [True: 0, False: 0]
  |  Branch (895:57): [True: 0, False: 0]
  ------------------
  896|      0|                field_type == MZ_ZIP_EXTENSION_UNIX1) {
  ------------------
  |  |   92|      0|#define MZ_ZIP_EXTENSION_UNIX1          (0x000d)
  ------------------
  |  Branch (896:17): [True: 0, False: 0]
  ------------------
  897|      0|                err_mem = mz_stream_seek(file_extra_stream, field_length, MZ_SEEK_CUR);
  ------------------
  |  |   59|      0|#define MZ_SEEK_CUR                     (1)
  ------------------
  898|      0|                continue;
  899|      0|            }
  900|       |
  901|      0|            err = mz_stream_write_uint16(stream, field_type);
  902|      0|            if (err == MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (902:17): [True: 0, False: 0]
  ------------------
  903|      0|                err = mz_stream_write_uint16(stream, field_length);
  904|      0|            if (err == MZ_OK)
  ------------------
  |  |   21|      0|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (904:17): [True: 0, False: 0]
  ------------------
  905|      0|                err = mz_stream_copy(stream, file_extra_stream, field_length);
  906|      0|        }
  907|       |
  908|      0|        mz_stream_mem_delete(&file_extra_stream);
  909|      0|    }
  910|       |
  911|     85|    if (err == MZ_OK && !local && file_info->comment) {
  ------------------
  |  |   21|    170|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (911:9): [True: 0, False: 85]
  |  Branch (911:25): [True: 0, False: 0]
  |  Branch (911:35): [True: 0, False: 0]
  ------------------
  912|      0|        if (mz_stream_write(stream, file_info->comment, file_info->comment_size) != file_info->comment_size)
  ------------------
  |  Branch (912:13): [True: 0, False: 0]
  ------------------
  913|      0|            err = MZ_WRITE_ERROR;
  ------------------
  |  |   45|      0|#define MZ_WRITE_ERROR                  (-116)
  ------------------
  914|      0|    }
  915|       |
  916|     85|    return err;
  917|     85|}
mz_zip.c:mz_zip_entry_needs_zip64:
  551|     85|static int32_t mz_zip_entry_needs_zip64(mz_zip_file *file_info, uint8_t local, uint8_t *zip64) {
  552|     85|    uint32_t max_uncompressed_size = UINT32_MAX;
  553|     85|    uint8_t needs_zip64 = 0;
  554|       |
  555|     85|    if (!zip64)
  ------------------
  |  Branch (555:9): [True: 0, False: 85]
  ------------------
  556|      0|        return MZ_PARAM_ERROR;
  ------------------
  |  |   31|      0|#define MZ_PARAM_ERROR                  (-102)
  ------------------
  557|       |
  558|     85|    *zip64 = 0;
  559|       |
  560|     85|    if (local) {
  ------------------
  |  Branch (560:9): [True: 85, False: 0]
  ------------------
  561|       |        /* At local header we might not know yet whether compressed size will overflow unsigned
  562|       |           32-bit integer which might happen for high entropy data so we give it some cushion */
  563|       |
  564|     85|        max_uncompressed_size -= MZ_ZIP_UNCOMPR_SIZE64_CUSHION;
  ------------------
  |  |   75|     85|#define MZ_ZIP_UNCOMPR_SIZE64_CUSHION   (2 * 1024 * 1024)
  ------------------
  565|     85|    }
  566|       |
  567|     85|    needs_zip64 = (file_info->uncompressed_size >= max_uncompressed_size) ||
  ------------------
  |  Branch (567:19): [True: 0, False: 85]
  ------------------
  568|     85|                  (file_info->compressed_size >= UINT32_MAX);
  ------------------
  |  Branch (568:19): [True: 0, False: 85]
  ------------------
  569|       |
  570|     85|    if (!local) {
  ------------------
  |  Branch (570:9): [True: 0, False: 85]
  ------------------
  571|       |        /* Disk offset and number only used in central directory header */
  572|      0|        needs_zip64 |= (file_info->disk_offset >= UINT32_MAX) ||
  ------------------
  |  Branch (572:24): [True: 0, False: 0]
  ------------------
  573|      0|                       (file_info->disk_number >= UINT16_MAX);
  ------------------
  |  Branch (573:24): [True: 0, False: 0]
  ------------------
  574|      0|    }
  575|       |
  576|     85|    if (file_info->zip64 == MZ_ZIP64_AUTO) {
  ------------------
  |  |   98|     85|#define MZ_ZIP64_AUTO                   (0)
  ------------------
  |  Branch (576:9): [True: 52, False: 33]
  ------------------
  577|       |        /* If uncompressed size is unknown, assume zip64 for 64-bit data descriptors */
  578|     52|        if (local && file_info->uncompressed_size == 0) {
  ------------------
  |  Branch (578:13): [True: 52, False: 0]
  |  Branch (578:22): [True: 52, False: 0]
  ------------------
  579|       |            /* Don't use zip64 for local header directory entries */
  580|     52|            if (mz_zip_attrib_is_dir(file_info->external_fa, file_info->version_madeby) != MZ_OK) {
  ------------------
  |  |   21|     52|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (580:17): [True: 52, False: 0]
  ------------------
  581|     52|                *zip64 = 1;
  582|     52|            }
  583|     52|        }
  584|     52|        *zip64 |= needs_zip64;
  585|     52|    } else if (file_info->zip64 == MZ_ZIP64_FORCE) {
  ------------------
  |  |   99|     33|#define MZ_ZIP64_FORCE                  (1)
  ------------------
  |  Branch (585:16): [True: 1, False: 32]
  ------------------
  586|      1|        *zip64 = 1;
  587|     32|    } else if (file_info->zip64 == MZ_ZIP64_DISABLE) {
  ------------------
  |  |  100|     32|#define MZ_ZIP64_DISABLE                (2)
  ------------------
  |  Branch (587:16): [True: 1, False: 31]
  ------------------
  588|       |        /* Zip64 extension is required to zip file */
  589|      1|        if (needs_zip64)
  ------------------
  |  Branch (589:13): [True: 0, False: 1]
  ------------------
  590|      0|            return MZ_PARAM_ERROR;
  ------------------
  |  |   31|      0|#define MZ_PARAM_ERROR                  (-102)
  ------------------
  591|      1|    }
  592|       |
  593|     85|    return MZ_OK;
  ------------------
  |  |   21|     85|#define MZ_OK                           (0)  /* zlib */
  ------------------
  594|     85|}
mz_zip.c:mz_zip_invalid_date:
 2633|     13|static int32_t mz_zip_invalid_date(const struct tm *ptm) {
 2634|     13|#define datevalue_in_range(min, max, value) ((min) <= (value) && (value) <= (max))
 2635|     13|    return (!datevalue_in_range(0, 127 + 80, ptm->tm_year) ||  /* 1980-based year, allow 80 extra */
  ------------------
  |  | 2634|     26|#define datevalue_in_range(min, max, value) ((min) <= (value) && (value) <= (max))
  |  |  ------------------
  |  |  |  Branch (2634:46): [True: 13, False: 0]
  |  |  |  Branch (2634:66): [True: 13, False: 0]
  |  |  ------------------
  ------------------
 2636|     13|            !datevalue_in_range(0, 11, ptm->tm_mon) ||
  ------------------
  |  | 2634|     26|#define datevalue_in_range(min, max, value) ((min) <= (value) && (value) <= (max))
  |  |  ------------------
  |  |  |  Branch (2634:46): [True: 13, False: 0]
  |  |  |  Branch (2634:66): [True: 13, False: 0]
  |  |  ------------------
  ------------------
 2637|     13|            !datevalue_in_range(1, 31, ptm->tm_mday) ||
  ------------------
  |  | 2634|     26|#define datevalue_in_range(min, max, value) ((min) <= (value) && (value) <= (max))
  |  |  ------------------
  |  |  |  Branch (2634:46): [True: 13, False: 0]
  |  |  |  Branch (2634:66): [True: 13, False: 0]
  |  |  ------------------
  ------------------
 2638|     13|            !datevalue_in_range(0, 23, ptm->tm_hour) ||
  ------------------
  |  | 2634|     26|#define datevalue_in_range(min, max, value) ((min) <= (value) && (value) <= (max))
  |  |  ------------------
  |  |  |  Branch (2634:46): [True: 13, False: 0]
  |  |  |  Branch (2634:66): [True: 13, False: 0]
  |  |  ------------------
  ------------------
 2639|     13|            !datevalue_in_range(0, 59, ptm->tm_min) ||
  ------------------
  |  | 2634|     26|#define datevalue_in_range(min, max, value) ((min) <= (value) && (value) <= (max))
  |  |  ------------------
  |  |  |  Branch (2634:46): [True: 13, False: 0]
  |  |  |  Branch (2634:66): [True: 13, False: 0]
  |  |  ------------------
  ------------------
 2640|     13|            !datevalue_in_range(0, 59, ptm->tm_sec));
  ------------------
  |  | 2634|     13|#define datevalue_in_range(min, max, value) ((min) <= (value) && (value) <= (max))
  |  |  ------------------
  |  |  |  Branch (2634:46): [True: 13, False: 0]
  |  |  |  Branch (2634:66): [True: 13, False: 0]
  |  |  ------------------
  ------------------
 2641|     13|#undef datevalue_in_range
 2642|     13|}

LLVMFuzzerTestOneInput:
   28|    210|int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
   29|    210|    mz_zip_file file_info;
   30|    210|    void *fuzz_stream = NULL;
   31|    210|    void *stream = NULL;
   32|    210|    void *handle = NULL;
   33|    210|    int32_t err = MZ_OK;
  ------------------
  |  |   21|    210|#define MZ_OK                           (0)  /* zlib */
  ------------------
   34|    210|    uint16_t value16 = 0;
   35|    210|    uint8_t value8 = 0;
   36|    210|    int16_t compress_level = 0;
   37|    210|    int64_t fuzz_pos = 0;
   38|    210|    int32_t fuzz_length = 0;
   39|    210|    uint8_t *fuzz_buf = NULL;
   40|       |
   41|    210|    mz_stream_mem_create(&fuzz_stream);
   42|    210|    mz_stream_mem_set_buffer(fuzz_stream, (void *)data, (int32_t)size);
   43|       |
   44|    210|    memset(&file_info, 0, sizeof(file_info));
   45|       |
   46|    210|    file_info.flag = MZ_ZIP_FLAG_UTF8;
  ------------------
  |  |   85|    210|#define MZ_ZIP_FLAG_UTF8                (1 << 11)
  ------------------
   47|    210|    if ((mz_stream_read_uint8(fuzz_stream, &value8) == MZ_OK) && (value8 < 0x08)) {
  ------------------
  |  |   21|    210|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (47:9): [True: 210, False: 0]
  |  Branch (47:66): [True: 44, False: 166]
  ------------------
   48|     44|        if (mz_stream_read_uint16(fuzz_stream, &value16) == MZ_OK)
  ------------------
  |  |   21|     44|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (48:13): [True: 39, False: 5]
  ------------------
   49|     39|            file_info.flag = value16;
   50|     44|    }
   51|    210|    file_info.compression_method = MZ_COMPRESS_METHOD_DEFLATE;
  ------------------
  |  |   64|    210|#define MZ_COMPRESS_METHOD_DEFLATE      (8)
  ------------------
   52|    210|    if ((mz_stream_read_uint8(fuzz_stream, &value8) == MZ_OK) && (value8 < 0x08)) {
  ------------------
  |  |   21|    210|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (52:9): [True: 197, False: 13]
  |  Branch (52:66): [True: 78, False: 119]
  ------------------
   53|     78|        file_info.compression_method = MZ_COMPRESS_METHOD_STORE;
  ------------------
  |  |   63|     78|#define MZ_COMPRESS_METHOD_STORE        (0)
  ------------------
   54|    132|    } else if ((mz_stream_read_uint8(fuzz_stream, &value8) == MZ_OK) && (value8 < 0x08)) {
  ------------------
  |  |   21|    132|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (54:16): [True: 111, False: 21]
  |  Branch (54:73): [True: 58, False: 53]
  ------------------
   55|     58|        if (mz_stream_read_uint16(fuzz_stream, &value16) == MZ_OK)
  ------------------
  |  |   21|     58|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (55:13): [True: 54, False: 4]
  ------------------
   56|     54|            file_info.compression_method = value16;
   57|     58|    }
   58|       |
   59|    210|    if ((mz_stream_read_uint8(fuzz_stream, &value8) == MZ_OK) && (value8 < 0x08)) {
  ------------------
  |  |   21|    210|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (59:9): [True: 154, False: 56]
  |  Branch (59:66): [True: 73, False: 81]
  ------------------
   60|     73|        if (mz_stream_read_uint16(fuzz_stream, &value16) == MZ_OK)
  ------------------
  |  |   21|     73|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (60:13): [True: 67, False: 6]
  ------------------
   61|     67|            file_info.zip64 = value16;
   62|     73|    }
   63|       |
   64|    210|    file_info.filename = MZ_FUZZ_TEST_FILENAME;
  ------------------
  |  |   24|    210|#define MZ_FUZZ_TEST_FILENAME "foo"
  ------------------
   65|    210|    file_info.filename_size = (uint16_t)strlen(MZ_FUZZ_TEST_FILENAME);
  ------------------
  |  |   24|    210|#define MZ_FUZZ_TEST_FILENAME "foo"
  ------------------
   66|       |
   67|    210|    compress_level = MZ_COMPRESS_LEVEL_DEFAULT;
  ------------------
  |  |   71|    210|#define MZ_COMPRESS_LEVEL_DEFAULT       (-1)
  ------------------
   68|    210|    if ((mz_stream_read_uint8(fuzz_stream, &value8) == MZ_OK) && (value8 < 0x08)) {
  ------------------
  |  |   21|    210|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (68:9): [True: 112, False: 98]
  |  Branch (68:66): [True: 89, False: 23]
  ------------------
   69|     89|        if (mz_stream_read_uint16(fuzz_stream, &value16) == MZ_OK)
  ------------------
  |  |   21|     89|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (69:13): [True: 82, False: 7]
  ------------------
   70|     82|            compress_level = value16;
   71|     89|    }
   72|       |
   73|    210|    mz_stream_mem_create(&stream);
   74|    210|    mz_zip_create(&handle);
   75|       |
   76|    210|    err = mz_zip_open(handle, stream, MZ_OPEN_MODE_CREATE | MZ_OPEN_MODE_WRITE);
  ------------------
  |  |   54|    210|#define MZ_OPEN_MODE_CREATE             (0x08)
  ------------------
                  err = mz_zip_open(handle, stream, MZ_OPEN_MODE_CREATE | MZ_OPEN_MODE_WRITE);
  ------------------
  |  |   51|    210|#define MZ_OPEN_MODE_WRITE              (0x02)
  ------------------
   77|    210|    if (err == MZ_OK) {
  ------------------
  |  |   21|    210|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (77:9): [True: 210, False: 0]
  ------------------
   78|    210|        err = mz_zip_entry_write_open(handle, &file_info, compress_level, 0, NULL);
   79|    210|        if (err == MZ_OK) {
  ------------------
  |  |   21|    210|#define MZ_OK                           (0)  /* zlib */
  ------------------
  |  Branch (79:13): [True: 0, False: 210]
  ------------------
   80|      0|            mz_stream_mem_get_buffer_at_current(fuzz_stream, (const void **)&fuzz_buf);
   81|      0|            fuzz_pos = mz_stream_tell(fuzz_stream);
   82|      0|            mz_stream_mem_get_buffer_length(fuzz_stream, &fuzz_length);
   83|       |
   84|      0|            err = mz_zip_entry_write(handle, fuzz_buf, (fuzz_length - (int32_t)fuzz_pos));
   85|       |
   86|      0|            mz_zip_entry_close(handle);
   87|      0|        }
   88|       |
   89|    210|        mz_zip_close(handle);
   90|    210|    }
   91|       |
   92|    210|    mz_zip_delete(&handle);
   93|    210|    mz_stream_mem_delete(&stream);
   94|       |
   95|    210|    mz_stream_mem_delete(&fuzz_stream);
   96|       |
   97|    210|    return 0;
   98|    210|}

