osDir.h 2.7 KB
Newer Older
S
Shengliang Guan 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*
 * 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/>.
 */

S
Shengliang Guan 已提交
16 17
#ifndef _TD_OS_DIR_H_
#define _TD_OS_DIR_H_
S
Shengliang Guan 已提交
18

wafwerar's avatar
wafwerar 已提交
19
// If the error is in a third-party library, place this header file under the third-party library header file.
wafwerar's avatar
wafwerar 已提交
20
// When you want to use this feature, you should find or add the same function in the following section.
wafwerar's avatar
wafwerar 已提交
21 22 23 24 25 26 27 28 29
#ifndef ALLOW_FORBID_FUNC
    #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
#endif

S
Shengliang Guan 已提交
30 31 32 33
#ifdef __cplusplus
extern "C" {
#endif

34 35
#ifdef WINDOWS
#define TD_TMP_DIR_PATH "C:\\Windows\\Temp\\"
wafwerar's avatar
wafwerar 已提交
36 37 38 39 40 41 42 43
#define TD_CFG_DIR_PATH "C:\\TDengine\\cfg\\"
#define TD_DATA_DIR_PATH "C:\\TDengine\\data\\"
#define TD_LOG_DIR_PATH "C:\\TDengine\\log\\"
#elif defined(_TD_DARWIN_64)
#define TD_TMP_DIR_PATH "/tmp/taosd/"
#define TD_CFG_DIR_PATH "/usr/local/etc/taos/"
#define TD_DATA_DIR_PATH "/usr/local/var/lib/taos/"
#define TD_LOG_DIR_PATH "/usr/local/var/log/taos/"
44 45
#else
#define TD_TMP_DIR_PATH "/tmp/"
wafwerar's avatar
wafwerar 已提交
46 47 48
#define TD_CFG_DIR_PATH "/etc/taos/"
#define TD_DATA_DIR_PATH "/var/lib/taos/"
#define TD_LOG_DIR_PATH "/var/log/taos/"
49 50
#endif

wafwerar's avatar
wafwerar 已提交
51 52 53 54
typedef struct TdDir *TdDirPtr;
typedef struct TdDirEntry *TdDirEntryPtr;


55
void    taosRemoveDir(const char *dirname);
wafwerar's avatar
wafwerar 已提交
56
bool    taosDirExist(const char *dirname);
57
int32_t taosMkDir(const char *dirname);
wafwerar's avatar
wafwerar 已提交
58
int32_t taosMulMkDir(const char *dirname);
wafwerar's avatar
wafwerar 已提交
59
int32_t taosMulModeMkDir(const char *dirname, int mode);
S
config  
Shengliang Guan 已提交
60
void    taosRemoveOldFiles(const char *dirname, int32_t keepDays);
S
config  
Shengliang Guan 已提交
61
int32_t taosExpandDir(const char *dirname, char *outname, int32_t maxlen);
wafwerar's avatar
wafwerar 已提交
62
int32_t taosRealPath(char *dirname, char *realPath, int32_t maxlen);
63
bool    taosIsDir(const char *dirname);
wafwerar's avatar
wafwerar 已提交
64 65 66 67 68 69 70
char*   taosDirName(char *dirname);
char*   taosDirEntryBaseName(char *dirname);

TdDirPtr      taosOpenDir(const char *dirname);
TdDirEntryPtr taosReadDir(TdDirPtr pDir);
bool          taosDirEntryIsDir(TdDirEntryPtr pDirEntry);
char*         taosGetDirEntryName(TdDirEntryPtr pDirEntry);
wafwerar's avatar
wafwerar 已提交
71
int32_t       taosCloseDir(TdDirPtr *ppDir);
S
Shengliang Guan 已提交
72 73 74 75 76

#ifdef __cplusplus
}
#endif

S
Shengliang Guan 已提交
77
#endif /*_TD_OS_DIR_H_*/