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

Method truncate

src/jrd/replication/ChangeLog.cpp:262–288  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

260}
261
262void ChangeLog::Segment::truncate()
263{
264 fb_assert(m_header != &m_builtinHeader);
265
266 const auto length = m_header->hdr_length;
267
268 unmapHeader();
269
270#ifdef WIN_NT
271 LARGE_INTEGER newSize;
272 newSize.QuadPart = (ULONGLONG) length;
273
274 const auto hndl = (HANDLE) _get_osfhandle(m_handle);
275 const auto ret = SetFilePointer(hndl, newSize.LowPart, &newSize.HighPart, FILE_BEGIN);
276 if (ret != INVALID_SET_FILE_POINTER)
277 SetEndOfFile(hndl);
278#else
279 os_utils::ftruncate(m_handle, length);
280#endif
281
282 // Truncation is known to be error-prone in Windows CS, which does not allow to truncate
283 // a file with a mapping open by some other process (ERROR_USER_MAPPED_FILE is returned).
284 // But we may safely ignore the result, because truncation here is just a storage/copying
285 // optimization, it's not critical from the archiving POV.
286
287 mapHeader();
288}
289
290void ChangeLog::Segment::flush(bool data)
291{

Callers 1

archiveExecuteMethod · 0.45

Calls 1

ftruncateFunction · 0.85

Tested by

no test coverage detected