| 347 | } |
| 348 | |
| 349 | static inline i64 DoSeek(FHANDLE h, i64 offset, SeekDir origin) noexcept { |
| 350 | if (h == INVALID_FHANDLE) { |
| 351 | return -1L; |
| 352 | } |
| 353 | #if defined(_win_) |
| 354 | static ui32 dir[] = {FILE_BEGIN, FILE_CURRENT, FILE_END}; |
| 355 | LARGE_INTEGER pos; |
| 356 | pos.QuadPart = offset; |
| 357 | pos.LowPart = ::SetFilePointer(h, pos.LowPart, &pos.HighPart, dir[origin]); |
| 358 | if (pos.LowPart == INVALID_SET_FILE_POINTER && GetLastError() != NO_ERROR) { |
| 359 | pos.QuadPart = -1; |
| 360 | } |
| 361 | return pos.QuadPart; |
| 362 | #elif defined(_unix_) |
| 363 | static int dir[] = {SEEK_SET, SEEK_CUR, SEEK_END}; |
| 364 | #if defined(_sun_) |
| 365 | return ::llseek(h, (offset_t)offset, dir[origin]); |
| 366 | #else |
| 367 | return ::lseek(h, (off_t)offset, dir[origin]); |
| 368 | #endif |
| 369 | #else |
| 370 | #error unsupported platform |
| 371 | #endif |
| 372 | } |
| 373 | |
| 374 | i64 TFileHandle::GetPosition() const noexcept { |
| 375 | return DoSeek(Fd_, 0, sCur); |
no outgoing calls
no test coverage detected