osFile.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_FILE_H_
#define _TD_OS_FILE_H_
S
Shengliang Guan 已提交
18 19 20 21 22

#ifdef __cplusplus
extern "C" {
#endif

S
Shengliang Guan 已提交
23 24
#include "osSocket.h"

S
TD-4088  
Shengliang Guan 已提交
25 26 27 28 29 30
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
typedef int32_t FileFd;
#else
typedef int32_t FileFd;
#endif

S
Shengliang Guan 已提交
31 32 33 34 35 36 37 38 39 40
#define FD_INITIALIZER ((int32_t)-1)

#ifndef PATH_MAX
#define PATH_MAX 256
#endif

int32_t taosLockFile(FileFd fd);
int32_t taosUnLockFile(FileFd fd);

int32_t taosUmaskFile(FileFd fd);
S
Shengliang Guan 已提交
41

S
Shengliang Guan 已提交
42 43
int32_t taosStatFile(const char *path, int64_t *size, int32_t *mtime);
int32_t taosFStatFile(FileFd fd, int64_t *size, int32_t *mtime);
S
TD-4088  
Shengliang Guan 已提交
44

S
Shengliang Guan 已提交
45 46
FileFd taosOpenFileWrite(const char *path);
FileFd taosOpenFileCreateWrite(const char *path);
47 48
FileFd taosOpenFileCreateWriteTrunc(const char *path);
FileFd taosOpenFileCreateWriteAppend(const char *path);
S
Shengliang Guan 已提交
49
FileFd taosOpenFileRead(const char *path);
50
FileFd taosOpenFileReadWrite(const char *path);
S
Shengliang Guan 已提交
51 52 53 54 55 56

int64_t taosLSeekFile(FileFd fd, int64_t offset, int32_t whence);
int32_t taosFtruncateFile(FileFd fd, int64_t length);
int32_t taosFsyncFile(FileFd fd);

int64_t taosReadFile(FileFd fd, void *buf, int64_t count);
H
more  
Hongze Cheng 已提交
57
int64_t taosWriteFile(FileFd fd, const void *buf, int64_t count);
S
Shengliang Guan 已提交
58 59 60

void taosCloseFile(FileFd fd);

S
Shengliang Guan 已提交
61 62
int32_t taosRenameFile(const char *oldName, const char *newName);
int64_t taosCopyFile(const char *from, const char *to);
S
Shengliang Guan 已提交
63 64

void taosGetTmpfilePath(const char *inputTmpDir, const char *fileNamePrefix, char *dstPath);
S
TD-4088  
Shengliang Guan 已提交
65 66 67

int64_t taosSendFile(SocketFd dfd, FileFd sfd, int64_t *offset, int64_t size);
int64_t taosFSendFile(FILE *outfile, FILE *infile, int64_t *offset, int64_t size);
S
TD-1912  
Shengliang Guan 已提交
68

S
Shengliang Guan 已提交
69 70 71 72
#ifdef __cplusplus
}
#endif

S
Shengliang Guan 已提交
73
#endif /*_TD_OS_FILE_H_*/