Use GetFileSize instead of GetFileSizeEx on Windows

This commit is contained in:
vitaut
2015-03-16 08:52:23 -07:00
parent c6d3a73201
commit 5aecd4947f
3 changed files with 20 additions and 12 deletions
+7 -5
View File
@@ -105,15 +105,17 @@ errno_t test::sopen_s(
static LONGLONG max_file_size() { return std::numeric_limits<LONGLONG>::max(); }
BOOL test::GetFileSizeEx(HANDLE hFile, PLARGE_INTEGER lpFileSize) {
DWORD test::GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh) {
if (fstat_sim == ERROR) {
SetLastError(ERROR_ACCESS_DENIED);
return FALSE;
}
BOOL result = ::GetFileSizeEx(hFile, lpFileSize);
if (fstat_sim == MAX_SIZE)
lpFileSize->QuadPart = max_file_size();
return result;
if (fstat_sim == MAX_SIZE) {
DWORD max = std::numeric_limits<DWORD>::max();
*lpFileSizeHig = max >> 1;
return max;
}
return ::GetFileSize(hFile, lpFileSizeHigh);
}
#endif
+1 -1
View File
@@ -51,7 +51,7 @@ typedef unsigned size_t;
typedef int ssize_t;
errno_t sopen_s(
int* pfh, const char *filename, int oflag, int shflag, int pmode);
BOOL GetFileSizeEx(HANDLE hFile, PLARGE_INTEGER lpFileSize);
DWORD GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh);
#endif
int close(int fildes);