提交 b6fb79dc 编写于 作者: B Bomin Zhang

fix td-900: support both config dir & file

上级 dd703941
...@@ -308,11 +308,21 @@ bool taosReadGlobalCfg() { ...@@ -308,11 +308,21 @@ bool taosReadGlobalCfg() {
sprintf(fileName, "%s/taos.cfg", configDir); sprintf(fileName, "%s/taos.cfg", configDir);
FILE* fp = fopen(fileName, "r"); FILE* fp = fopen(fileName, "r");
if (fp == NULL) {
struct stat s;
if (stat(configDir, &s) != 0 || (!S_ISREG(s.st_mode) && !S_ISLNK(s.st_mode))) {
//return true to follow behavior before file support
return true;
}
fp = fopen(configDir, "r");
if (fp == NULL) {
return false;
}
}
size_t len = 1024; size_t len = 1024;
line = calloc(1, len); line = calloc(1, len);
if (fp != NULL) {
while (!feof(fp)) { while (!feof(fp)) {
memset(line, 0, len); memset(line, 0, len);
...@@ -338,7 +348,6 @@ bool taosReadGlobalCfg() { ...@@ -338,7 +348,6 @@ bool taosReadGlobalCfg() {
} }
fclose(fp); fclose(fp);
}
tfree(line); tfree(line);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册