| 614 | } |
| 615 | |
| 616 | uint64_t LocalFileSystem::getFileSize(const FileInfo& fileInfo) const { |
| 617 | auto localFileInfo = fileInfo.constPtrCast<LocalFileInfo>(); |
| 618 | #ifdef _WIN32 |
| 619 | LARGE_INTEGER size; |
| 620 | if (!GetFileSizeEx((HANDLE)localFileInfo->handle, &size)) { |
| 621 | auto error = GetLastError(); |
| 622 | throw IOException(std::format("Cannot read size of file. path: {} - Error {}: {}", |
| 623 | fileInfo.path, error, systemErrMessage(error))); |
| 624 | } |
| 625 | return size.QuadPart; |
| 626 | #else |
| 627 | struct stat s {}; |
| 628 | if (fstat(localFileInfo->fd, &s) == -1) { |
| 629 | throw IOException(std::format("Cannot read size of file. path: {} - Error {}: {}", |
| 630 | fileInfo.path, errno, posixErrMessage())); |
| 631 | } |
| 632 | DASSERT(s.st_size >= 0); |
| 633 | return s.st_size; |
| 634 | #endif |
| 635 | } |
| 636 | |
| 637 | } // namespace common |
| 638 | } // namespace lbug |
no test coverage detected