vimpunk / mio

Cross-platform C++11 header-only library for memory mapped file IO
MIT License
1.71k stars 157 forks source link

Get file size error #86

Open LoveChina-3000 opened 2 years ago

LoveChina-3000 commented 2 years ago

In line 879 code,On 32-bite ,Get file size error,I modified part of the code 。

inline unsigned __int64 query_file_size(file_handle_type handle, std::error_code& error) { error.clear();

ifdef _WIN32

// LARGE_INTEGER file_size; // if(::GetFileSizeEx(handle, &file_size) == 0) // { // error = detail::last_error(); // return 0; // } //return static_cast(file_size.QuadPart);

DWORD dwFileSizeHigh;
__int64 qwFileSize = GetFileSize(handle, &dwFileSizeHigh);
qwFileSize += (((_int64)dwFileSizeHigh) << 32);
return qwFileSize;

else // POSIX

struct stat sbuf;
if(::fstat(handle, &sbuf) == -1)
{
    error = detail::last_error();
    return 0;
}
return sbuf.st_size;

endif

}