MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / getFileSize

Method getFileSize

src/common/file_system/local_file_system.cpp:616–635  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

614}
615
616uint64_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

Callers 1

readFromFileMethod · 0.45

Calls 2

systemErrMessageFunction · 0.85
posixErrMessageFunction · 0.85

Tested by

no test coverage detected