GCC Code Coverage Report


Directory: src/gate/
File: src/gate/encode/cxx_tarstreams.cpp
Date: 2025-09-14 13:10:38
Exec Total Coverage
Lines: 89 104 85.6%
Functions: 29 32 90.6%
Branches: 10 30 33.3%

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/tarstreams.hpp"
29 #include "gate/exceptions.hpp"
30
31 namespace gate
32 {
33 namespace enc
34 {
35
36 5 TarEntry::TarEntry()
37 {
38 5 gate_tarentry_t* ptr = static_cast<gate_tarentry_t*>(this);
39 5 Mem::clear(*ptr);
40 5 }
41 1 TarEntry::TarEntry(gate_tarentry_t const& entry)
42 {
43 1 gate_tarentry_t* ptr = static_cast<gate_tarentry_t*>(this);
44 1 Mem::copy(*ptr, entry);
45 1 }
46
47
48 3 String TarEntry::getPath() const
49 {
50 3 return String(this->path);
51 }
52 3 void TarEntry::setPath(String const& value)
53 {
54 3 value.copyTo(this->path, sizeof(this->path));
55 3 }
56
57 1 enumint_t TarEntry::getAttributes() const
58 {
59 1 return this->attribs;
60 }
61 2 void TarEntry::setAttributes(enumint_t value)
62 {
63 2 this->attribs = value;
64 2 }
65
66 1 enumint_t TarEntry::getAccessBits() const
67 {
68 1 return this->access;
69 }
70 1 void TarEntry::setAccessBits(enumint_t value)
71 {
72 1 this->access = value;
73 1 }
74
75 2 uint64_t TarEntry::getSize() const
76 {
77 2 return this->size;
78 }
79 1 void TarEntry::setSize(uint64_t value)
80 {
81 1 this->size = value;
82 1 }
83
84 1 Time TarEntry::getTimeModified() const
85 {
86 1 return Time::fromTimestamp(this->time_modified);
87 }
88 1 void TarEntry::setTimeModified(Time const& value)
89 {
90 1 this->time_modified = value.timestamp;
91 1 }
92
93 1 Time TarEntry::getTimeAccessed() const
94 {
95 1 return Time::fromTimestamp(this->time_accessed);
96 }
97 1 void TarEntry::setTimeAccessed(Time const& value)
98 {
99 1 this->time_accessed = value.timestamp;
100 1 }
101
102 1 uint32_t TarEntry::getOwnerId() const
103 {
104 1 return this->owner_id;
105 }
106 1 void TarEntry::setOwnerId(uint32_t value)
107 {
108 1 this->owner_id = value;
109 1 }
110
111 1 uint32_t TarEntry::getGroupId() const
112 {
113 1 return this->group_id;
114 }
115 1 void TarEntry::setGroupId(uint32_t value)
116 {
117 1 this->group_id = value;
118 1 }
119
120 1 String TarEntry::getOwner() const
121 {
122 1 return String(this->owner_name);
123 }
124 1 String TarEntry::getGroup() const
125 {
126 1 return String(this->group_name);
127 }
128
129
130
131
132 1 TarWriter::TarWriter(Stream& outputstream)
133 {
134 1 result_t result = gate_tarwriter_create(&this->impl, outputstream.c_impl());
135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 GATEXX_CHECK_ERROR(result);
136 1 }
137 2 TarWriter::~TarWriter() noexcept
138 {
139 1 gate_tarwriter_destroy(&this->impl);
140 1 }
141
142 1 void TarWriter::add(gate_tarentry_t const& entry, Stream& content)
143 {
144 1 result_t result = gate_tarwriter_add(&this->impl, &entry, content.c_impl());
145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 GATEXX_CHECK_EXCEPTION(result);
146 1 }
147 1 void TarWriter::add(gate_tarentry_t const& entry, void const* data)
148 {
149 1 result_t result = gate_tarwriter_add_data(&this->impl, &entry, data);
150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 GATEXX_CHECK_EXCEPTION(result);
151 1 }
152 1 void TarWriter::flush()
153 {
154 1 result_t result = gate_tarwriter_flush(&this->impl);
155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 GATEXX_CHECK_EXCEPTION(result);
156 1 }
157
158
159
160 1 TarReader::TarReader(Stream& inputstream)
161 {
162 1 result_t result = gate_tarreader_create(&this->impl, inputstream.c_impl());
163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 GATEXX_CHECK_ERROR(result);
164 1 }
165 2 TarReader::~TarReader() noexcept
166 {
167 1 gate_tarreader_destroy(&this->impl);
168 1 }
169
170 TarEntry TarReader::getFirstEntry()
171 {
172 TarEntry entry;
173 result_t result = gate_tarreader_get_first_entry(&this->impl, &entry);
174 GATEXX_CHECK_EXCEPTION(result);
175 return entry;
176 }
177 3 bool_t TarReader::getNextEntry(TarEntry& entry)
178 {
179 3 result_t result = gate_tarreader_get_next_entry(&this->impl, &entry);
180
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if (GATE_RESULT_ENDOFSTREAM == result)
181 {
182 1 return false;
183 }
184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 GATEXX_CHECK_EXCEPTION(result);
185 2 return true;
186 }
187 TarEntry TarReader::findEntry(String const& path)
188 {
189 TarEntry entry;
190 result_t result = gate_tarreader_find_entry(&this->impl, path.c_impl(), &entry);
191 GATEXX_CHECK_EXCEPTION(result);
192 return entry;
193 }
194 2 uint64_t TarReader::extractContent(Stream& outputTarget)
195 {
196 2 uint64_t ret = 0;
197
1/2
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 result_t result = gate_tarreader_extract_content(&this->impl, outputTarget.c_impl(), &ret);
198
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
2 GATEXX_CHECK_EXCEPTION(result);
199 2 return ret;
200 }
201 uint64_t TarReader::skipContent()
202 {
203 uint64_t ret = 0;
204 result_t result = gate_tarreader_skip_content(&this->impl, &ret);
205 GATEXX_CHECK_EXCEPTION(result);
206 return ret;
207 }
208
209
210 } // end of namespace enc
211 } // end of namespace gate
212