fix:adapt to windows

This commit is contained in:
wangmm0220 2023-11-08 10:28:45 +08:00
parent b709d43fee
commit 07aa749fcd
3 changed files with 11 additions and 4 deletions

View File

@ -237,6 +237,12 @@ void syslog(int unused, const char *format, ...);
#define TD_DIRSEP "/" #define TD_DIRSEP "/"
#endif #endif
#if defined(_WIN32)
#define TD_DIRSEP_CHAR '\\'
#else
#define TD_DIRSEP_CHAR '/'
#endif
#define TD_LOCALE_LEN 64 #define TD_LOCALE_LEN 64
#define TD_CHARSET_LEN 64 #define TD_CHARSET_LEN 64
#define TD_TIMEZONE_LEN 96 #define TD_TIMEZONE_LEN 96

View File

@ -825,8 +825,8 @@ int32_t s3GetObjectsByPrefix(const char *prefix, const char* path){
const char* tmp = strchr(object, '/'); const char* tmp = strchr(object, '/');
tmp = (tmp == NULL) ? object : tmp + 1; tmp = (tmp == NULL) ? object : tmp + 1;
char fileName[PATH_MAX] = {0}; char fileName[PATH_MAX] = {0};
if(path[strlen(path) - 1] != '/'){ if(path[strlen(path) - 1] != TD_DIRSEP_CHAR){
snprintf(fileName, PATH_MAX, "%s/%s", path, tmp); snprintf(fileName, PATH_MAX, "%s%s%s", path, TD_DIRSEP, tmp);
}else{ }else{
snprintf(fileName, PATH_MAX, "%s%s", path, tmp); snprintf(fileName, PATH_MAX, "%s%s", path, tmp);
} }

View File

@ -478,7 +478,7 @@ static int uploadCheckpointToS3(char* id, char* path){
taosDirEntryIsDir(de)) continue; taosDirEntryIsDir(de)) continue;
char filename[PATH_MAX] = {0}; char filename[PATH_MAX] = {0};
if(path[strlen(path - 1)] == '/'){ if(path[strlen(path - 1)] == TD_DIRSEP_CHAR){
snprintf(filename, sizeof(filename), "%s%s", path, name); snprintf(filename, sizeof(filename), "%s%s", path, name);
}else{ }else{
snprintf(filename, sizeof(filename), "%s%s%s", path, TD_DIRSEP, name); snprintf(filename, sizeof(filename), "%s%s%s", path, TD_DIRSEP, name);
@ -491,6 +491,7 @@ static int uploadCheckpointToS3(char* id, char* path){
taosCloseDir(&pDir); taosCloseDir(&pDir);
return -1; return -1;
} }
stDebug("[s3] upload checkpoint:%s", filename);
} }
taosCloseDir(&pDir); taosCloseDir(&pDir);
@ -548,7 +549,7 @@ int deleteCheckpoint(char* id){
int deleteCheckpointFile(char* id, char* name){ int deleteCheckpointFile(char* id, char* name){
char object[128] = {0}; char object[128] = {0};
snprintf(object, sizeof(object), "%s%s%s", id, TD_DIRSEP, name); snprintf(object, sizeof(object), "%s/%s", id, name);
char *tmp = object; char *tmp = object;
s3DeleteObjects((const char**)&tmp, 1); s3DeleteObjects((const char**)&tmp, 1);
return 0; return 0;