MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / copyTo

Method copyTo

src/jrd/replication/ChangeLog.cpp:170–212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

168}
169
170void ChangeLog::Segment::copyTo(const PathName& filename) const
171{
172 fb_assert(m_header != &m_builtinHeader);
173
174 if (os_utils::lseek(m_handle, 0, SEEK_SET) != 0)
175 raiseIOError("seek", m_filename.c_str(), ERRNO);
176
177 const auto totalLength = m_header->hdr_length;
178 fb_assert(totalLength > sizeof(SegmentHeader));
179
180 const auto dstHandle = os_utils::openCreateSharedFile(filename.c_str(), O_TRUNC | O_BINARY);
181
182 AutoFile dstFile(dstHandle);
183
184 Vector<UCHAR, COPY_BLOCK_SIZE> buffer;
185 const auto data = buffer.begin();
186
187 for (FB_UINT64 offset = 0; offset < totalLength; offset += COPY_BLOCK_SIZE)
188 {
189 const auto remaining = totalLength - offset;
190 const SINT64 length = MIN(remaining, COPY_BLOCK_SIZE);
191
192 if (::read(m_handle, data, length) != length)
193 {
194 const ISC_STATUS errcode = ERRNO;
195
196 dstFile.release();
197 unlink(filename.c_str());
198 raiseIOError("read", m_filename.c_str(), errcode);
199 }
200
201 if (::write(dstFile, data, length) != length)
202 {
203 const ISC_STATUS errcode = ERRNO;
204
205 dstFile.release();
206 unlink(filename.c_str());
207 raiseIOError("write", filename.c_str(), errcode);
208 }
209 }
210
211 flushFile(dstHandle);
212}
213
214void ChangeLog::Segment::append(ULONG length, const UCHAR* data)
215{

Callers 6

archiveExecuteMethod · 0.45
~IscStatusMethod · 0.45
notImplementedMethod · 0.45
doPrepareMethod · 0.45
fetchMethod · 0.45
load_pluginsMethod · 0.45

Calls 8

lseekFunction · 0.85
raiseIOErrorFunction · 0.85
flushFileFunction · 0.85
openCreateSharedFileFunction · 0.50
unlinkFunction · 0.50
c_strMethod · 0.45
beginMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected