Skip to content

Commit

Permalink
Merge pull request #1587 from kuzudb/windows-file-size
Browse files Browse the repository at this point in the history
Use GetFileSizeEX instead of GetFileSize on windows
  • Loading branch information
andyfengHKU committed May 31, 2023
2 parents 35b8694 + 991c54c commit ca8ba4b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/common/file_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ FileInfo::~FileInfo() {

int64_t FileInfo::getFileSize() {
#ifdef _WIN32
return GetFileSize((HANDLE)handle, nullptr);
LARGE_INTEGER size;
if (!GetFileSizeEx((HANDLE)handle, &size)) {
auto error = GetLastError();
throw common::StorageException(
StringUtils::string_format("Cannot read size of file. path: {} - Error {}: {}", path,
error, std::system_category().message(error)));
}
return size.QuadPart;
#else
struct stat s;
if (fstat(fd, &s) == -1) {
Expand Down

0 comments on commit ca8ba4b

Please sign in to comment.