TDengine/include/os/osDir.h

108 lines
3.5 KiB
C
Raw Normal View History

2020-07-31 06:18:23 +00:00
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
2021-09-30 09:10:36 +00:00
#ifndef _TD_OS_DIR_H_
#define _TD_OS_DIR_H_
2020-07-31 06:18:23 +00:00
2022-03-09 07:47:29 +00:00
// If the error is in a third-party library, place this header file under the third-party library header file.
2022-03-21 16:54:21 +00:00
// When you want to use this feature, you should find or add the same function in the following section.
2022-03-09 07:47:29 +00:00
#ifndef ALLOW_FORBID_FUNC
2022-10-13 03:09:43 +00:00
#define opendir OPENDIR_FUNC_TAOS_FORBID
#define readdir READDIR_FUNC_TAOS_FORBID
#define closedir CLOSEDIR_FUNC_TAOS_FORBID
#define dirname DIRNAME_FUNC_TAOS_FORBID
#undef basename
#define basename BASENAME_FUNC_TAOS_FORBID
2022-03-09 07:47:29 +00:00
#endif
2020-07-31 06:18:23 +00:00
#ifdef __cplusplus
extern "C" {
#endif
#if defined(CUS_NAME) || defined(CUS_PROMPT) || defined(CUS_EMAIL)
#include "cus_name.h"
#endif
#ifdef WINDOWS
2022-10-13 03:09:43 +00:00
#define TD_TMP_DIR_PATH "C:\\Windows\\Temp\\"
#ifdef CUS_NAME
#define TD_CFG_DIR_PATH "C:\\"CUS_NAME"\\cfg\\"
#define TD_DATA_DIR_PATH "C:\\"CUS_NAME"\\data\\"
#define TD_LOG_DIR_PATH "C:\\"CUS_NAME"\\log\\"
#else
2022-10-13 03:09:43 +00:00
#define TD_CFG_DIR_PATH "C:\\TDengine\\cfg\\"
2022-06-01 03:33:15 +00:00
#define TD_DATA_DIR_PATH "C:\\TDengine\\data\\"
2022-10-13 03:09:43 +00:00
#define TD_LOG_DIR_PATH "C:\\TDengine\\log\\"
#endif // CUS_NAME
2022-06-01 03:33:15 +00:00
#elif defined(_TD_DARWIN_64)
#ifdef CUS_PROMPT
#define TD_TMP_DIR_PATH "/tmp/"CUS_PROMPT"d/"
#define TD_CFG_DIR_PATH "/etc/"CUS_PROMPT"/"
#define TD_DATA_DIR_PATH "/var/lib/"CUS_PROMPT"/"
#define TD_LOG_DIR_PATH "/var/log/"CUS_PROMPT"/"
#else
2022-10-13 03:09:43 +00:00
#define TD_TMP_DIR_PATH "/tmp/taosd/"
#define TD_CFG_DIR_PATH "/etc/taos/"
#define TD_DATA_DIR_PATH "/var/lib/taos/"
2022-10-13 03:09:43 +00:00
#define TD_LOG_DIR_PATH "/var/log/taos/"
#endif // CUS_PROMPT
#else
2022-10-13 03:09:43 +00:00
#define TD_TMP_DIR_PATH "/tmp/"
#ifdef CUS_PROMPT
#define TD_CFG_DIR_PATH "/etc/"CUS_PROMPT"/"
#define TD_DATA_DIR_PATH "/var/lib/"CUS_PROMPT"/"
#define TD_LOG_DIR_PATH "/var/log/"CUS_PROMPT"/"
#else
2022-10-13 03:09:43 +00:00
#define TD_CFG_DIR_PATH "/etc/taos/"
2022-06-01 03:33:15 +00:00
#define TD_DATA_DIR_PATH "/var/lib/taos/"
2022-10-13 03:09:43 +00:00
#define TD_LOG_DIR_PATH "/var/log/taos/"
#endif // CUS_PROMPT
#endif
2022-10-13 03:09:43 +00:00
typedef struct TdDir *TdDirPtr;
2022-03-09 07:47:29 +00:00
typedef struct TdDirEntry *TdDirEntryPtr;
2024-07-27 10:33:08 +00:00
#define TAOS_DIRNAME(name) ((void)taosDirName(name))
void taosRemoveDir(const char *dirname);
2022-04-22 01:54:27 +00:00
bool taosDirExist(const char *dirname);
int32_t taosMkDir(const char *dirname);
2022-04-12 12:23:00 +00:00
int32_t taosMulMkDir(const char *dirname);
2023-08-25 02:15:52 +00:00
int32_t taosMulModeMkDir(const char *dirname, int mode, bool checkAccess);
2022-02-24 06:16:42 +00:00
void taosRemoveOldFiles(const char *dirname, int32_t keepDays);
2022-02-22 05:59:51 +00:00
int32_t taosExpandDir(const char *dirname, char *outname, int32_t maxlen);
2022-04-22 01:54:27 +00:00
int32_t taosRealPath(char *dirname, char *realPath, int32_t maxlen);
bool taosIsDir(const char *dirname);
2022-10-13 03:09:43 +00:00
char *taosDirName(char *dirname);
char *taosDirEntryBaseName(char *dirname);
2022-12-08 02:50:24 +00:00
void taosGetCwd(char *buf, int32_t len);
2022-03-09 07:47:29 +00:00
TdDirPtr taosOpenDir(const char *dirname);
TdDirEntryPtr taosReadDir(TdDirPtr pDir);
bool taosDirEntryIsDir(TdDirEntryPtr pDirEntry);
2022-10-13 03:09:43 +00:00
char *taosGetDirEntryName(TdDirEntryPtr pDirEntry);
2022-04-22 01:54:27 +00:00
int32_t taosCloseDir(TdDirPtr *ppDir);
2020-07-31 06:18:23 +00:00
#ifdef __cplusplus
}
#endif
2021-09-30 09:10:36 +00:00
#endif /*_TD_OS_DIR_H_*/