enh: lock and file adaption for windows

This commit is contained in:
kailixu 2023-09-20 15:40:39 +08:00
parent 97c87bdbdc
commit 3bb5a5f1d4
1 changed files with 2 additions and 5 deletions

View File

@ -456,8 +456,7 @@ int64_t taosPReadFile(TdFilePtr pFile, void *buf, int64_t count, int64_t offset)
return -1; return -1;
} }
#ifdef WINDOWS #ifdef WINDOWS
int64_t ret = 0; int64_t ret = 0;
OVERLAPPED ol = {0}; OVERLAPPED ol = {0};
ol.OffsetHigh = (uint32_t)((offset & 0xFFFFFFFF00000000LL) >> 0x20); ol.OffsetHigh = (uint32_t)((offset & 0xFFFFFFFF00000000LL) >> 0x20);
ol.Offset = (uint32_t)(offset & 0xFFFFFFFFLL); ol.Offset = (uint32_t)(offset & 0xFFFFFFFFLL);
@ -465,7 +464,6 @@ int64_t taosPReadFile(TdFilePtr pFile, void *buf, int64_t count, int64_t offset)
HANDLE handle = (HANDLE)_get_osfhandle(pFile->fd); HANDLE handle = (HANDLE)_get_osfhandle(pFile->fd);
SetLastError(0); SetLastError(0);
bool result = ReadFile(handle, buf, count, &ret, &ol); bool result = ReadFile(handle, buf, count, &ret, &ol);
if (!result && GetLastError() != ERROR_HANDLE_EOF) { if (!result && GetLastError() != ERROR_HANDLE_EOF) {
errno = GetLastError(); errno = GetLastError();
return -1; return -1;
@ -533,8 +531,7 @@ int64_t taosPWriteFile(TdFilePtr pFile, const void *buf, int64_t count, int64_t
return 0; return 0;
} }
#ifdef WINDOWS #ifdef WINDOWS
int64_t ret = 0; int64_t ret = 0;
OVERLAPPED ol = {0}; OVERLAPPED ol = {0};
pl.OffsetHigh = (uint32_t)((offset & 0xFFFFFFFF00000000LL) >> 0x20); pl.OffsetHigh = (uint32_t)((offset & 0xFFFFFFFF00000000LL) >> 0x20);
pl.Offset = (uint32_t)(offset & 0xFFFFFFFFLL); pl.Offset = (uint32_t)(offset & 0xFFFFFFFFLL);