| 472 | |
| 473 | |
| 474 | uint64 CFile::GetPosition() const |
| 475 | { |
| 476 | MULE_VALIDATE_STATE(IsOpened(), "Cannot get position in closed file."); |
| 477 | |
| 478 | std::lock_guard<std::recursive_mutex> lock(m_mutex); |
| 479 | |
| 480 | // Reported position must include any pending buffered bytes. |
| 481 | // Easiest is to drain so TELL_FD's answer is authoritative. |
| 482 | DrainWriteBuffer(); |
| 483 | |
| 484 | sint64 pos = TELL_FD(m_fd); |
| 485 | if (pos == wxInvalidOffset) { |
| 486 | throw CSeekFailureException(wxString("Failed to retrieve position in file: ") + wxSysErrorMsg()); |
| 487 | } |
| 488 | |
| 489 | return pos; |
| 490 | } |
| 491 | |
| 492 | |
| 493 | uint64 CFile::GetLength() const |