未验证 提交 032d9761 编写于 作者: wafwerar's avatar wafwerar 提交者: GitHub

Merge pull request #12024 from taosdata/fix/ZhiqiangWang/fix-14989-fix-win-open-file-error

fix(os): fix win open file error.
...@@ -228,7 +228,7 @@ endif() ...@@ -228,7 +228,7 @@ endif()
# iconv # iconv
if(${BUILD_WITH_ICONV}) if(${BUILD_WITH_ICONV})
add_subdirectory(iconv EXCLUDE_FROM_ALL) add_library(iconv STATIC iconv/win_iconv.c)
endif(${BUILD_WITH_ICONV}) endif(${BUILD_WITH_ICONV})
# wingetopt # wingetopt
......
...@@ -1404,7 +1404,7 @@ static void tdSRowPrint(STSRow *row, STSchema *pSchema, const char* tag) { ...@@ -1404,7 +1404,7 @@ static void tdSRowPrint(STSRow *row, STSchema *pSchema, const char* tag) {
printf("%s >>>", tag); printf("%s >>>", tag);
for (int i = 0; i < pSchema->numOfCols; ++i) { for (int i = 0; i < pSchema->numOfCols; ++i) {
STColumn *stCol = pSchema->columns + i; STColumn *stCol = pSchema->columns + i;
SCellVal sVal = {.valType = 255, .val = NULL}; SCellVal sVal = { 255, NULL};
if (!tdSTSRowIterNext(&iter, stCol->colId, stCol->type, &sVal)) { if (!tdSTSRowIterNext(&iter, stCol->colId, stCol->type, &sVal)) {
break; break;
} }
......
...@@ -184,14 +184,14 @@ TEST_F(MndTestSdb, 01_Write) { ...@@ -184,14 +184,14 @@ TEST_F(MndTestSdb, 01_Write) {
taosRemoveDir(opt.path); taosRemoveDir(opt.path);
SSdbTable strTable = { SSdbTable strTable = {
.sdbType = SDB_USER, SDB_USER,
.keyType = SDB_KEY_BINARY, SDB_KEY_BINARY,
.deployFp = (SdbDeployFp)strDefault, (SdbDeployFp)strDefault,
.encodeFp = (SdbEncodeFp)strEncode, (SdbEncodeFp)strEncode,
.decodeFp = (SdbDecodeFp)strDecode, (SdbDecodeFp)strDecode,
.insertFp = (SdbInsertFp)strInsert, (SdbInsertFp)strInsert,
.updateFp = (SdbUpdateFp)strUpdate, (SdbUpdateFp)strUpdate,
.deleteFp = (SdbDeleteFp)strDelete, (SdbDeleteFp)strDelete,
}; };
pSdb = sdbInit(&opt); pSdb = sdbInit(&opt);
...@@ -304,14 +304,14 @@ TEST_F(MndTestSdb, 01_Read) { ...@@ -304,14 +304,14 @@ TEST_F(MndTestSdb, 01_Read) {
taosRemoveDir(opt.path); taosRemoveDir(opt.path);
SSdbTable strTable = { SSdbTable strTable = {
.sdbType = SDB_USER, SDB_USER,
.keyType = SDB_KEY_BINARY, SDB_KEY_BINARY,
.deployFp = (SdbDeployFp)strDefault, (SdbDeployFp)strDefault,
.encodeFp = (SdbEncodeFp)strEncode, (SdbEncodeFp)strEncode,
.decodeFp = (SdbDecodeFp)strDecode, (SdbDecodeFp)strDecode,
.insertFp = (SdbInsertFp)strInsert, (SdbInsertFp)strInsert,
.updateFp = (SdbUpdateFp)strDelete, (SdbUpdateFp)strUpdate,
.deleteFp = (SdbDeleteFp)strUpdate, (SdbDeleteFp)strDelete,
}; };
pSdb = sdbInit(&opt); pSdb = sdbInit(&opt);
......
...@@ -170,7 +170,7 @@ static int32_t doScalarFunctionUnique2(SScalarParam *pInput, int32_t inputNum, S ...@@ -170,7 +170,7 @@ static int32_t doScalarFunctionUnique2(SScalarParam *pInput, int32_t inputNum, S
double *out = (double *)pOutputData->pData; double *out = (double *)pOutputData->pData;
double result; double result;
int32_t numOfRows = MAX(pInput[0].numOfRows, pInput[1].numOfRows); int32_t numOfRows = TMAX(pInput[0].numOfRows, pInput[1].numOfRows);
if (pInput[0].numOfRows == pInput[1].numOfRows) { if (pInput[0].numOfRows == pInput[1].numOfRows) {
for (int32_t i = 0; i < numOfRows; ++i) { for (int32_t i = 0; i < numOfRows; ++i) {
if (colDataIsNull_s(pInputData[0], i) || if (colDataIsNull_s(pInputData[0], i) ||
......
...@@ -40,11 +40,11 @@ int wordexp(char *words, wordexp_t *pwordexp, int flags) { ...@@ -40,11 +40,11 @@ int wordexp(char *words, wordexp_t *pwordexp, int flags) {
memset(pwordexp->wordPos, 0, 1025); memset(pwordexp->wordPos, 0, 1025);
if (_fullpath(pwordexp->wordPos, words, 1024) == NULL) { if (_fullpath(pwordexp->wordPos, words, 1024) == NULL) {
pwordexp->we_wordv[0] = words; pwordexp->we_wordv[0] = words;
printf("failed to parse relative path:%s to abs path", words); printf("failed to parse relative path:%s to abs path\n", words);
return -1; return -1;
} }
printf("parse relative path:%s to abs path:%s", words, pwordexp->wordPos); printf("parse relative path:%s to abs path:%s\n", words, pwordexp->wordPos);
return 0; return 0;
} }
......
...@@ -22,20 +22,6 @@ ...@@ -22,20 +22,6 @@
#define W_OK 2 #define W_OK 2
#define R_OK 4 #define R_OK 4
#if defined(_MSDOS)
#define open _open
#endif
#if defined(_WIN32)
extern int openA(const char *, int, ...); /* MsvcLibX ANSI version of open */
extern int openU(const char *, int, ...); /* MsvcLibX UTF-8 version of open */
#if defined(_UTF8_SOURCE) || defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
#define open openU
#else /* _ANSI_SOURCE */
#define open openA
#endif /* defined(_UTF8_SOURCE) */
#endif /* defined(_WIN32) */
#define _SEND_FILE_STEP_ 1000 #define _SEND_FILE_STEP_ 1000
#else #else
...@@ -228,9 +214,6 @@ int32_t taosDevInoFile(const char *path, int64_t *stDev, int64_t *stIno) { ...@@ -228,9 +214,6 @@ int32_t taosDevInoFile(const char *path, int64_t *stDev, int64_t *stIno) {
void autoDelFileListAdd(const char *path) { return; } void autoDelFileListAdd(const char *path) { return; }
TdFilePtr taosOpenFile(const char *path, int32_t tdFileOptions) { TdFilePtr taosOpenFile(const char *path, int32_t tdFileOptions) {
#ifdef WINDOWS
return NULL;
#else
int fd = -1; int fd = -1;
FILE *fp = NULL; FILE *fp = NULL;
if (tdFileOptions & TD_FILE_STREAM) { if (tdFileOptions & TD_FILE_STREAM) {
...@@ -263,7 +246,11 @@ TdFilePtr taosOpenFile(const char *path, int32_t tdFileOptions) { ...@@ -263,7 +246,11 @@ TdFilePtr taosOpenFile(const char *path, int32_t tdFileOptions) {
access |= (tdFileOptions & TD_FILE_APPEND) ? O_APPEND : 0; access |= (tdFileOptions & TD_FILE_APPEND) ? O_APPEND : 0;
access |= (tdFileOptions & TD_FILE_TEXT) ? O_TEXT : 0; access |= (tdFileOptions & TD_FILE_TEXT) ? O_TEXT : 0;
access |= (tdFileOptions & TD_FILE_EXCL) ? O_EXCL : 0; access |= (tdFileOptions & TD_FILE_EXCL) ? O_EXCL : 0;
#ifdef WINDOWS
fd = _open(path, access, _S_IREAD|_S_IWRITE);
#else
fd = open(path, access, S_IRWXU | S_IRWXG | S_IRWXO); fd = open(path, access, S_IRWXU | S_IRWXG | S_IRWXO);
#endif
if (fd == -1) { if (fd == -1) {
return NULL; return NULL;
} }
...@@ -286,7 +273,6 @@ TdFilePtr taosOpenFile(const char *path, int32_t tdFileOptions) { ...@@ -286,7 +273,6 @@ TdFilePtr taosOpenFile(const char *path, int32_t tdFileOptions) {
pFile->fp = fp; pFile->fp = fp;
pFile->refId = 0; pFile->refId = 0;
return pFile; return pFile;
#endif
} }
int64_t taosCloseFile(TdFilePtr *ppFile) { int64_t taosCloseFile(TdFilePtr *ppFile) {
......
...@@ -866,6 +866,16 @@ void taosSetCoreDump(bool enable) { ...@@ -866,6 +866,16 @@ void taosSetCoreDump(bool enable) {
SysNameInfo taosGetSysNameInfo() { SysNameInfo taosGetSysNameInfo() {
#ifdef WINDOWS #ifdef WINDOWS
SysNameInfo info = {0};
DWORD dwVersion = GetVersion();
tstrncpy(info.sysname, getenv("OS"), sizeof(info.sysname));
tstrncpy(info.nodename, getenv("COMPUTERNAME"), sizeof(info.nodename));
sprintf_s(info.release, sizeof(info.release), "%d", dwVersion & 0x0F);
sprintf_s(info.version, sizeof(info.release), "%d", (dwVersion >> 8) & 0x0F);
tstrncpy(info.machine, getenv("PROCESSOR_ARCHITECTURE"), sizeof(info.machine));
return info;
#elif defined(_TD_DARWIN_64) #elif defined(_TD_DARWIN_64)
SysNameInfo info = {0}; SysNameInfo info = {0};
......
...@@ -687,13 +687,13 @@ int32_t cfgLoadFromEnvFile(SConfig *pConfig, const char *envFile) { ...@@ -687,13 +687,13 @@ int32_t cfgLoadFromEnvFile(SConfig *pConfig, const char *envFile) {
const char *filepath = ".env"; const char *filepath = ".env";
if (envFile != NULL && strlen(envFile)>0) { if (envFile != NULL && strlen(envFile)>0) {
if (!taosCheckExistFile(envFile)) { if (!taosCheckExistFile(envFile)) {
uError("fial to load env file: %s", envFile); uError("failed to load env file: %s", envFile);
return -1; return -1;
} }
filepath = envFile; filepath = envFile;
}else { }else {
if (!taosCheckExistFile(filepath)) { if (!taosCheckExistFile(filepath)) {
uInfo("fial to load env file: %s", filepath); uInfo("failed to load env file: %s", filepath);
return 0; return 0;
} }
} }
...@@ -826,7 +826,7 @@ int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) { ...@@ -826,7 +826,7 @@ int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) {
if (strncmp(url, "jsonFile", 8) == 0) { if (strncmp(url, "jsonFile", 8) == 0) {
char *filepath = p; char *filepath = p;
if (!taosCheckExistFile(filepath)) { if (!taosCheckExistFile(filepath)) {
uError("fial to load json file: %s", filepath); uError("failed to load json file: %s", filepath);
return -1; return -1;
} }
...@@ -957,13 +957,13 @@ int32_t cfgGetApollUrl(const char **envCmd, const char *envFile, char* apolloUrl ...@@ -957,13 +957,13 @@ int32_t cfgGetApollUrl(const char **envCmd, const char *envFile, char* apolloUrl
const char *filepath = ".env"; const char *filepath = ".env";
if (envFile != NULL && strlen(envFile)>0) { if (envFile != NULL && strlen(envFile)>0) {
if (!taosCheckExistFile(envFile)) { if (!taosCheckExistFile(envFile)) {
uError("fial to load env file: %s", envFile); uError("failed to load env file: %s", envFile);
return -1; return -1;
} }
filepath = envFile; filepath = envFile;
}else { }else {
if (!taosCheckExistFile(filepath)) { if (!taosCheckExistFile(filepath)) {
uInfo("fial to load env file: %s", filepath); uInfo("failed to load env file: %s", filepath);
return 0; return 0;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册