libcsdbg  1.28
C++ exception (and generic) stack trace debug library
filebuf & csdbg::filebuf::seek_to ( i32  offset,
bool  rel = false 
)
virtual

Seek the file pointer to a new position.

Parameters
[in]offsetthe new position
[in]reltrue to seek relatively to the current position
Returns
*this
Exceptions
csdbg::exception

Definition at line 282 of file filebuf.cpp.

References csdbg::streambuf::m_handle, m_path, and unlikely.

283 {
284  i32 whence = (rel) ? SEEK_CUR : SEEK_SET;
285  i32 retval = lseek(m_handle, offset, whence);
286  if ( unlikely(retval < 0) )
287  throw exception(
288  "failed to seek file '%s' to offset %d (errno %d - %s)",
289  m_path,
290  offset,
291  errno,
292  strerror(errno)
293  );
294 
295  return *this;
296 }
i32 m_handle
Stream handle (descriptor)
Definition: streambuf.hpp:43
int i32
32-bit signed integer
Definition: config.hpp:82
i8 * m_path
Output file path.
Definition: filebuf.hpp:37
#define unlikely(expr)
Offer a hint (negative) to the pipeline branch predictor.
Definition: config.hpp:349