fix: make mul dir error.

This commit is contained in:
afwerar 2022-04-12 20:23:00 +08:00
parent f937c5b889
commit 1cb0680061
3 changed files with 11 additions and 1 deletions

View File

@ -38,6 +38,7 @@ typedef struct TdDirEntry *TdDirEntryPtr;
void taosRemoveDir(const char *dirname); void taosRemoveDir(const char *dirname);
bool taosDirExist(char *dirname); bool taosDirExist(char *dirname);
int32_t taosMkDir(const char *dirname); int32_t taosMkDir(const char *dirname);
int32_t taosMulMkDir(const char *dirname);
void taosRemoveOldFiles(const char *dirname, int32_t keepDays); void taosRemoveOldFiles(const char *dirname, int32_t keepDays);
int32_t taosExpandDir(const char *dirname, char *outname, int32_t maxlen); int32_t taosExpandDir(const char *dirname, char *outname, int32_t maxlen);
int32_t taosRealPath(char *dirname, int32_t maxlen); int32_t taosRealPath(char *dirname, int32_t maxlen);

View File

@ -616,7 +616,7 @@ int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDi
taosSetAllDebugFlag(cfgGetItem(pCfg, "debugFlag")->i32); taosSetAllDebugFlag(cfgGetItem(pCfg, "debugFlag")->i32);
if (taosMkDir(tsLogDir) != 0) { if (taosMulMkDir(tsLogDir) != 0) {
uError("failed to create dir:%s since %s", tsLogDir, terrstr()); uError("failed to create dir:%s since %s", tsLogDir, terrstr());
cfgCleanup(pCfg); cfgCleanup(pCfg);
return -1; return -1;

View File

@ -68,6 +68,15 @@ void taosRemoveDir(const char *dirname) {
bool taosDirExist(char *dirname) { return taosCheckExistFile(dirname); } bool taosDirExist(char *dirname) { return taosCheckExistFile(dirname); }
int32_t taosMkDir(const char *dirname) { int32_t taosMkDir(const char *dirname) {
int32_t code = mkdir(dirname, 0755);
if (code < 0 && errno == EEXIST) {
return 0;
}
return code;
}
int32_t taosMulMkDir(const char *dirname) {
if (dirname == NULL) return -1; if (dirname == NULL) return -1;
char *temp = strdup(dirname); char *temp = strdup(dirname);
char *pos = temp; char *pos = temp;