fix(os): fix win open file error.
This commit is contained in:
parent
c934d00903
commit
f4f11fdc01
|
@ -228,7 +228,7 @@ endif()
|
|||
|
||||
# iconv
|
||||
if(${BUILD_WITH_ICONV})
|
||||
add_subdirectory(iconv EXCLUDE_FROM_ALL)
|
||||
add_library(iconv STATIC iconv/win_iconv.c)
|
||||
endif(${BUILD_WITH_ICONV})
|
||||
|
||||
# wingetopt
|
||||
|
|
|
@ -1404,7 +1404,7 @@ static void tdSRowPrint(STSRow *row, STSchema *pSchema, const char* tag) {
|
|||
printf("%s >>>", tag);
|
||||
for (int i = 0; i < pSchema->numOfCols; ++i) {
|
||||
STColumn *stCol = pSchema->columns + i;
|
||||
SCellVal sVal = {.valType = 255, .val = NULL};
|
||||
SCellVal sVal = { 255, NULL};
|
||||
if (!tdSTSRowIterNext(&iter, stCol->colId, stCol->type, &sVal)) {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -184,14 +184,14 @@ TEST_F(MndTestSdb, 01_Write) {
|
|||
taosRemoveDir(opt.path);
|
||||
|
||||
SSdbTable strTable = {
|
||||
.sdbType = SDB_USER,
|
||||
.keyType = SDB_KEY_BINARY,
|
||||
.deployFp = (SdbDeployFp)strDefault,
|
||||
.encodeFp = (SdbEncodeFp)strEncode,
|
||||
.decodeFp = (SdbDecodeFp)strDecode,
|
||||
.insertFp = (SdbInsertFp)strInsert,
|
||||
.updateFp = (SdbUpdateFp)strUpdate,
|
||||
.deleteFp = (SdbDeleteFp)strDelete,
|
||||
SDB_USER,
|
||||
SDB_KEY_BINARY,
|
||||
(SdbDeployFp)strDefault,
|
||||
(SdbEncodeFp)strEncode,
|
||||
(SdbDecodeFp)strDecode,
|
||||
(SdbInsertFp)strInsert,
|
||||
(SdbUpdateFp)strUpdate,
|
||||
(SdbDeleteFp)strDelete,
|
||||
};
|
||||
|
||||
pSdb = sdbInit(&opt);
|
||||
|
@ -304,14 +304,14 @@ TEST_F(MndTestSdb, 01_Read) {
|
|||
taosRemoveDir(opt.path);
|
||||
|
||||
SSdbTable strTable = {
|
||||
.sdbType = SDB_USER,
|
||||
.keyType = SDB_KEY_BINARY,
|
||||
.deployFp = (SdbDeployFp)strDefault,
|
||||
.encodeFp = (SdbEncodeFp)strEncode,
|
||||
.decodeFp = (SdbDecodeFp)strDecode,
|
||||
.insertFp = (SdbInsertFp)strInsert,
|
||||
.updateFp = (SdbUpdateFp)strDelete,
|
||||
.deleteFp = (SdbDeleteFp)strUpdate,
|
||||
SDB_USER,
|
||||
SDB_KEY_BINARY,
|
||||
(SdbDeployFp)strDefault,
|
||||
(SdbEncodeFp)strEncode,
|
||||
(SdbDecodeFp)strDecode,
|
||||
(SdbInsertFp)strInsert,
|
||||
(SdbUpdateFp)strUpdate,
|
||||
(SdbDeleteFp)strDelete,
|
||||
};
|
||||
|
||||
pSdb = sdbInit(&opt);
|
||||
|
|
|
@ -170,7 +170,7 @@ static int32_t doScalarFunctionUnique2(SScalarParam *pInput, int32_t inputNum, S
|
|||
double *out = (double *)pOutputData->pData;
|
||||
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) {
|
||||
for (int32_t i = 0; i < numOfRows; ++i) {
|
||||
if (colDataIsNull_s(pInputData[0], i) ||
|
||||
|
|
|
@ -40,11 +40,11 @@ int wordexp(char *words, wordexp_t *pwordexp, int flags) {
|
|||
memset(pwordexp->wordPos, 0, 1025);
|
||||
if (_fullpath(pwordexp->wordPos, words, 1024) == NULL) {
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,20 +22,6 @@
|
|||
#define W_OK 2
|
||||
#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
|
||||
|
||||
#else
|
||||
|
@ -228,9 +214,6 @@ int32_t taosDevInoFile(const char *path, int64_t *stDev, int64_t *stIno) {
|
|||
void autoDelFileListAdd(const char *path) { return; }
|
||||
|
||||
TdFilePtr taosOpenFile(const char *path, int32_t tdFileOptions) {
|
||||
#ifdef WINDOWS
|
||||
return NULL;
|
||||
#else
|
||||
int fd = -1;
|
||||
FILE *fp = NULL;
|
||||
if (tdFileOptions & TD_FILE_STREAM) {
|
||||
|
@ -263,7 +246,11 @@ TdFilePtr taosOpenFile(const char *path, int32_t tdFileOptions) {
|
|||
access |= (tdFileOptions & TD_FILE_APPEND) ? O_APPEND : 0;
|
||||
access |= (tdFileOptions & TD_FILE_TEXT) ? O_TEXT : 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);
|
||||
#endif
|
||||
if (fd == -1) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -286,7 +273,6 @@ TdFilePtr taosOpenFile(const char *path, int32_t tdFileOptions) {
|
|||
pFile->fp = fp;
|
||||
pFile->refId = 0;
|
||||
return pFile;
|
||||
#endif
|
||||
}
|
||||
|
||||
int64_t taosCloseFile(TdFilePtr *ppFile) {
|
||||
|
|
|
@ -866,6 +866,16 @@ void taosSetCoreDump(bool enable) {
|
|||
|
||||
SysNameInfo taosGetSysNameInfo() {
|
||||
#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)
|
||||
SysNameInfo info = {0};
|
||||
|
||||
|
|
|
@ -687,13 +687,13 @@ int32_t cfgLoadFromEnvFile(SConfig *pConfig, const char *envFile) {
|
|||
const char *filepath = ".env";
|
||||
if (envFile != NULL && strlen(envFile)>0) {
|
||||
if (!taosCheckExistFile(envFile)) {
|
||||
uError("fial to load env file: %s", envFile);
|
||||
uError("failed to load env file: %s", envFile);
|
||||
return -1;
|
||||
}
|
||||
filepath = envFile;
|
||||
}else {
|
||||
if (!taosCheckExistFile(filepath)) {
|
||||
uInfo("fial to load env file: %s", filepath);
|
||||
uInfo("failed to load env file: %s", filepath);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -826,7 +826,7 @@ int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) {
|
|||
if (strncmp(url, "jsonFile", 8) == 0) {
|
||||
char *filepath = p;
|
||||
if (!taosCheckExistFile(filepath)) {
|
||||
uError("fial to load json file: %s", filepath);
|
||||
uError("failed to load json file: %s", filepath);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -957,13 +957,13 @@ int32_t cfgGetApollUrl(const char **envCmd, const char *envFile, char* apolloUrl
|
|||
const char *filepath = ".env";
|
||||
if (envFile != NULL && strlen(envFile)>0) {
|
||||
if (!taosCheckExistFile(envFile)) {
|
||||
uError("fial to load env file: %s", envFile);
|
||||
uError("failed to load env file: %s", envFile);
|
||||
return -1;
|
||||
}
|
||||
filepath = envFile;
|
||||
}else {
|
||||
if (!taosCheckExistFile(filepath)) {
|
||||
uInfo("fial to load env file: %s", filepath);
|
||||
uInfo("failed to load env file: %s", filepath);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue