osDir.h 2.2 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 36 37 38 39
#ifdef WINDOWS
#define TD_TMP_DIR_PATH "C:\\Windows\\Temp\\"
#else
#define TD_TMP_DIR_PATH "/tmp/"
#endif

wafwerar's avatar
wafwerar 已提交
40 41 42 43
typedef struct TdDir *TdDirPtr;
typedef struct TdDirEntry *TdDirEntryPtr;


44
void    taosRemoveDir(const char *dirname);
wafwerar's avatar
wafwerar 已提交
45
bool    taosDirExist(const char *dirname);
46
int32_t taosMkDir(const char *dirname);
wafwerar's avatar
wafwerar 已提交
47
int32_t taosMulMkDir(const char *dirname);
S
config  
Shengliang Guan 已提交
48
void    taosRemoveOldFiles(const char *dirname, int32_t keepDays);
S
config  
Shengliang Guan 已提交
49
int32_t taosExpandDir(const char *dirname, char *outname, int32_t maxlen);
wafwerar's avatar
wafwerar 已提交
50
int32_t taosRealPath(char *dirname, char *realPath, int32_t maxlen);
51
bool    taosIsDir(const char *dirname);
wafwerar's avatar
wafwerar 已提交
52 53 54 55 56 57 58
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 已提交
59
int32_t       taosCloseDir(TdDirPtr *ppDir);
S
Shengliang Guan 已提交
60 61 62 63 64

#ifdef __cplusplus
}
#endif

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