Merge pull request #24740 from taosdata/fix/xsren/TD-28551/fileNotExistErrorCode
fix: file not exist on windows
This commit is contained in:
commit
129da0ab5c
|
@ -119,6 +119,8 @@ int32_t taosSetFileHandlesLimit();
|
||||||
|
|
||||||
int32_t taosLinkFile(char *src, char *dst);
|
int32_t taosLinkFile(char *src, char *dst);
|
||||||
|
|
||||||
|
bool lastErrorIsFileNotExist();
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -632,6 +632,11 @@ int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, in
|
||||||
return writeLen;
|
return writeLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool lastErrorIsFileNotExist() {
|
||||||
|
DWORD dwError = GetLastError();
|
||||||
|
return dwError == ERROR_FILE_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
int taosOpenFileNotStream(const char *path, int32_t tdFileOptions) {
|
int taosOpenFileNotStream(const char *path, int32_t tdFileOptions) {
|
||||||
int access = O_BINARY;
|
int access = O_BINARY;
|
||||||
|
@ -1028,6 +1033,8 @@ int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, in
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool lastErrorIsFileNotExist() { return errno == ENOENT; }
|
||||||
|
|
||||||
#endif // WINDOWS
|
#endif // WINDOWS
|
||||||
|
|
||||||
TdFilePtr taosOpenFile(const char *path, int32_t tdFileOptions) {
|
TdFilePtr taosOpenFile(const char *path, int32_t tdFileOptions) {
|
||||||
|
|
|
@ -350,7 +350,7 @@ void taosResetLog() {
|
||||||
static bool taosCheckFileIsOpen(char *logFileName) {
|
static bool taosCheckFileIsOpen(char *logFileName) {
|
||||||
TdFilePtr pFile = taosOpenFile(logFileName, TD_FILE_WRITE);
|
TdFilePtr pFile = taosOpenFile(logFileName, TD_FILE_WRITE);
|
||||||
if (pFile == NULL) {
|
if (pFile == NULL) {
|
||||||
if (errno == ENOENT) {
|
if (lastErrorIsFileNotExist()) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
printf("\nfailed to open log file:%s, reason:%s\n", logFileName, strerror(errno));
|
printf("\nfailed to open log file:%s, reason:%s\n", logFileName, strerror(errno));
|
||||||
|
|
Loading…
Reference in New Issue