TDengine/include/os/osFile.h

74 lines
2.1 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 08:41:02 +00:00
#ifndef _TD_OS_FILE_H_
#define _TD_OS_FILE_H_
2020-07-31 06:18:23 +00:00
#ifdef __cplusplus
extern "C" {
#endif
2021-01-14 09:25:32 +00:00
#include "osSocket.h"
2021-05-08 04:07:18 +00:00
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
typedef int32_t FileFd;
#else
typedef int32_t FileFd;
#endif
2021-09-30 08:41:02 +00:00
#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);
2020-07-31 07:23:05 +00:00
2021-09-30 08:41:02 +00:00
int32_t taosStatFile(const char *path, int64_t *size, int32_t *mtime);
int32_t taosFStatFile(FileFd fd, int64_t *size, int32_t *mtime);
2021-05-08 04:07:18 +00:00
2021-09-30 08:41:02 +00:00
FileFd taosOpenFileWrite(const char *path);
FileFd taosOpenFileCreateWrite(const char *path);
FileFd taosOpenFileCreateWriteTrunc(const char *path);
FileFd taosOpenFileCreateWriteAppend(const char *path);
2021-09-30 08:41:02 +00:00
FileFd taosOpenFileRead(const char *path);
FileFd taosOpenFileReadWrite(const char *path);
2021-09-30 08:41:02 +00:00
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);
int64_t taosWriteFile(FileFd fd, void *buf, int64_t count);
void taosCloseFile(FileFd fd);
int32_t taosRenameFile(char *oldName, char *newName);
int64_t taosCopyFile(char *from, char *to);
void taosGetTmpfilePath(const char *inputTmpDir, const char *fileNamePrefix, char *dstPath);
2021-05-08 04:07:18 +00:00
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);
2020-11-03 14:55:14 +00:00
2020-07-31 06:18:23 +00:00
#ifdef __cplusplus
}
#endif
2021-09-30 08:41:02 +00:00
#endif /*_TD_OS_FILE_H_*/