| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* GATE PROJECT LICENSE: | ||
| 2 | +----------------------------------------------------------------------------+ | ||
| 3 | | Copyright(c) 2018-2025, Stefan Meislinger <sm@opengate.at> | | ||
| 4 | | All rights reserved. | | ||
| 5 | | | | ||
| 6 | | Redistribution and use in source and binary forms, with or without | | ||
| 7 | | modification, are permitted provided that the following conditions are met:| | ||
| 8 | | | | ||
| 9 | | 1. Redistributions of source code must retain the above copyright notice, | | ||
| 10 | | this list of conditions and the following disclaimer. | | ||
| 11 | | 2. Redistributions in binary form must reproduce the above copyright | | ||
| 12 | | notice, this list of conditions and the following disclaimer in the | | ||
| 13 | | documentation and/or other materials provided with the distribution. | | ||
| 14 | | | | ||
| 15 | | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"| | ||
| 16 | | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | | ||
| 17 | | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | ||
| 18 | | ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | | ||
| 19 | | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | ||
| 20 | | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | ||
| 21 | | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | ||
| 22 | | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | ||
| 23 | | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | ||
| 24 | | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | | ||
| 25 | | THE POSSIBILITY OF SUCH DAMAGE. | | ||
| 26 | +----------------------------------------------------------------------------+ | ||
| 27 | */ | ||
| 28 | #include "gate/encode/zipstreams.hpp" | ||
| 29 | |||
| 30 | namespace gate | ||
| 31 | { | ||
| 32 | namespace enc | ||
| 33 | { | ||
| 34 | |||
| 35 | 4 | ZipEntry::ZipEntry() | |
| 36 | { | ||
| 37 | 4 | gate_zipentry_t* self = static_cast<gate_zipentry_t*>(this); | |
| 38 | 4 | gate_zipentry_init(self, NULL, 0, 0, 0, NULL); | |
| 39 | 4 | } | |
| 40 | |||
| 41 | 4 | String ZipEntry::getPath() const | |
| 42 | { | ||
| 43 | 4 | return String(this->path); | |
| 44 | } | ||
| 45 | 2 | void ZipEntry::setPath(String const& value) | |
| 46 | { | ||
| 47 | 2 | value.copyTo(this->path, sizeof(this->path)); | |
| 48 | 2 | } | |
| 49 | |||
| 50 | ✗ | String ZipEntry::getComment() const | |
| 51 | { | ||
| 52 | ✗ | return String(this->comment); | |
| 53 | } | ||
| 54 | ✗ | void ZipEntry::setComment(String const& value) | |
| 55 | { | ||
| 56 | ✗ | value.copyTo(this->comment, sizeof(this->comment)); | |
| 57 | ✗ | } | |
| 58 | |||
| 59 | ✗ | Time ZipEntry::getModifiedDate() const | |
| 60 | { | ||
| 61 | ✗ | return Time(this->modified_date); | |
| 62 | } | ||
| 63 | 1 | void ZipEntry::setModifiedDate(Time const& value) | |
| 64 | { | ||
| 65 | 1 | this->modified_date = value; | |
| 66 | 1 | } | |
| 67 | 4 | uint64_t ZipEntry::getSize() const | |
| 68 | { | ||
| 69 | 4 | return this->size; | |
| 70 | } | ||
| 71 | 1 | void ZipEntry::setSize(uint64_t value) | |
| 72 | { | ||
| 73 | 1 | this->size = value; | |
| 74 | 1 | } | |
| 75 | ✗ | enumint_t ZipEntry::getAttributes() const | |
| 76 | { | ||
| 77 | ✗ | return this->attribs; | |
| 78 | } | ||
| 79 | 1 | void ZipEntry::setAttributes(enumint_t value) | |
| 80 | { | ||
| 81 | 1 | this->attribs = value; | |
| 82 | 1 | } | |
| 83 | |||
| 84 | ✗ | enumint_t ZipEntry::getAccessBits() const | |
| 85 | { | ||
| 86 | ✗ | return this->access; | |
| 87 | } | ||
| 88 | 1 | void ZipEntry::setAccessBits(enumint_t value) | |
| 89 | { | ||
| 90 | 1 | this->access = value; | |
| 91 | 1 | } | |
| 92 | |||
| 93 | |||
| 94 | 1 | ZipWriter::ZipWriter(Stream& outputStream) | |
| 95 | { | ||
| 96 | 1 | result_t result = gate_zipwriter_create(&this->impl, outputStream.c_impl()); | |
| 97 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | GATEXX_CHECK_ERROR(result); |
| 98 | 1 | } | |
| 99 | 2 | ZipWriter::~ZipWriter() noexcept | |
| 100 | { | ||
| 101 | 1 | gate_zipwriter_destroy(&this->impl); | |
| 102 | 1 | } | |
| 103 | |||
| 104 | ✗ | void ZipWriter::add(ZipEntry const& entry, Stream& content) | |
| 105 | { | ||
| 106 | ✗ | result_t result = gate_zipwriter_add(&this->impl, &entry, content.c_impl()); | |
| 107 | ✗ | GATEXX_CHECK_EXCEPTION(result); | |
| 108 | ✗ | } | |
| 109 | 2 | void ZipWriter::add(ZipEntry const& entry, void const* data) | |
| 110 | { | ||
| 111 | 2 | result_t result = gate_zipwriter_add_data(&this->impl, &entry, data); | |
| 112 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | GATEXX_CHECK_EXCEPTION(result); |
| 113 | 2 | } | |
| 114 | 1 | void ZipWriter::flush() | |
| 115 | { | ||
| 116 | 1 | result_t result = gate_zipwriter_flush(&this->impl); | |
| 117 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | GATEXX_CHECK_EXCEPTION(result); |
| 118 | 1 | } | |
| 119 | |||
| 120 | |||
| 121 | |||
| 122 | |||
| 123 | 3 | ZipReader::ZipReader(Stream& inputStream) | |
| 124 | { | ||
| 125 | 3 | result_t result = gate_zipreader_create(&this->impl, inputStream.c_impl()); | |
| 126 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | GATEXX_CHECK_ERROR(result); |
| 127 | 3 | } | |
| 128 | 6 | ZipReader::~ZipReader() noexcept | |
| 129 | { | ||
| 130 | 3 | gate_zipreader_destroy(&this->impl); | |
| 131 | 3 | } | |
| 132 | |||
| 133 | 1 | ZipEntry ZipReader::getFirstEntry() | |
| 134 | { | ||
| 135 | 1 | ZipEntry entry; | |
| 136 | 1 | result_t result = gate_zipreader_get_first_entry(&this->impl, &entry); | |
| 137 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | GATEXX_CHECK_EXCEPTION(result); |
| 138 | 1 | return entry; | |
| 139 | } | ||
| 140 | 1 | bool_t ZipReader::getNextEntry(ZipEntry& entry) | |
| 141 | { | ||
| 142 | 1 | result_t result = gate_zipreader_get_next_entry(&this->impl, &entry); | |
| 143 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (result == GATE_RESULT_ENDOFSTREAM) |
| 144 | { | ||
| 145 | ✗ | return false; | |
| 146 | } | ||
| 147 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | GATEXX_CHECK_EXCEPTION(result); |
| 148 | 1 | return true; | |
| 149 | } | ||
| 150 | 2 | ZipEntry ZipReader::findEntry(String const& path) | |
| 151 | { | ||
| 152 | 2 | ZipEntry entry; | |
| 153 | 2 | result_t result = gate_zipreader_find_entry(&this->impl, path.c_impl(), &entry); | |
| 154 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | GATEXX_CHECK_EXCEPTION(result); |
| 155 | 2 | return entry; | |
| 156 | } | ||
| 157 | 2 | void ZipReader::extractContent(Stream& outputTarget) | |
| 158 | { | ||
| 159 | 2 | result_t result = gate_zipreader_extract_content(&this->impl, outputTarget.c_impl()); | |
| 160 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | GATEXX_CHECK_EXCEPTION(result); |
| 161 | 2 | } | |
| 162 | |||
| 163 | |||
| 164 | } // end of namespace enc | ||
| 165 | } // end of namespace gate | ||
| 166 |