1060ff233Sopenharmony_ci/*
2060ff233Sopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd.
3060ff233Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4060ff233Sopenharmony_ci * you may not use this file except in compliance with the License.
5060ff233Sopenharmony_ci * You may obtain a copy of the License at
6060ff233Sopenharmony_ci *
7060ff233Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8060ff233Sopenharmony_ci *
9060ff233Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10060ff233Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11060ff233Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12060ff233Sopenharmony_ci * See the License for the specific language governing permissions and
13060ff233Sopenharmony_ci * limitations under the License.
14060ff233Sopenharmony_ci */
15060ff233Sopenharmony_ci
16060ff233Sopenharmony_ci#ifndef SOFTBUS_ADAPTER_FILE_H
17060ff233Sopenharmony_ci#define SOFTBUS_ADAPTER_FILE_H
18060ff233Sopenharmony_ci
19060ff233Sopenharmony_ci#include <stdint.h>
20060ff233Sopenharmony_ci
21060ff233Sopenharmony_ci#ifdef __cplusplus
22060ff233Sopenharmony_ci#if __cplusplus
23060ff233Sopenharmony_ciextern "C" {
24060ff233Sopenharmony_ci#endif
25060ff233Sopenharmony_ci#endif
26060ff233Sopenharmony_ci
27060ff233Sopenharmony_ci#define SOFTBUS_PATH_SEPRATOR '/'
28060ff233Sopenharmony_ci#define SOFTBUS_MAX_PATH_LEN 256
29060ff233Sopenharmony_ci
30060ff233Sopenharmony_ci/* unistd.h */
31060ff233Sopenharmony_ci#define SOFTBUS_F_OK (0)
32060ff233Sopenharmony_ci#define SOFTBUS_X_OK (1)
33060ff233Sopenharmony_ci#define SOFTBUS_W_OK (2)
34060ff233Sopenharmony_ci#define SOFTBUS_R_OK (4)
35060ff233Sopenharmony_ci
36060ff233Sopenharmony_ci/* fcntl.h */
37060ff233Sopenharmony_ci#define SOFTBUS_O_RDONLY (00)
38060ff233Sopenharmony_ci#define SOFTBUS_O_WRONLY (01)
39060ff233Sopenharmony_ci#define SOFTBUS_O_RDWR (02)
40060ff233Sopenharmony_ci#define SOFTBUS_O_CREATE (0100)
41060ff233Sopenharmony_ci#define SOFTBUS_O_TRUNC (01000)
42060ff233Sopenharmony_ci
43060ff233Sopenharmony_ci#define SOFTBUS_S_IRUSR (0400)
44060ff233Sopenharmony_ci#define SOFTBUS_S_IWUSR (0200)
45060ff233Sopenharmony_ci#define SOFTBUS_S_IXUSR (0100)
46060ff233Sopenharmony_ci/* File operation */
47060ff233Sopenharmony_ciint32_t SoftBusReadFile(int32_t fd, void *readBuf, uint32_t maxLen);
48060ff233Sopenharmony_ciint32_t SoftBusReadFullFile(const char *fileName, char *readBuf, uint32_t maxLen);
49060ff233Sopenharmony_ciint32_t SoftBusWriteFile(const char *fileName, const char *writeBuf, uint32_t len);
50060ff233Sopenharmony_ciint32_t SoftBusWriteFileFd(int32_t fd, const char *writeBuf, uint32_t len);
51060ff233Sopenharmony_ciint32_t SoftBusOpenFile(const char *fileName, int32_t flags);
52060ff233Sopenharmony_ciint32_t SoftBusOpenFileWithPerms(const char *fileName, int32_t flags, int32_t perms);
53060ff233Sopenharmony_civoid SoftBusRemoveFile(const char *fileName);
54060ff233Sopenharmony_civoid SoftBusCloseFile(int32_t fd);
55060ff233Sopenharmony_ciint64_t SoftBusPreadFile(int32_t fd, void *buf, uint64_t readBytes, uint64_t offset);
56060ff233Sopenharmony_ciint64_t SoftBusPwriteFile(int32_t fd, const void *buf, uint64_t writeBytes, uint64_t offset);
57060ff233Sopenharmony_ciint32_t SoftBusAccessFile(const char *pathName, int32_t mode);
58060ff233Sopenharmony_ciint32_t SoftBusMakeDir(const char *pathName, int32_t mode);
59060ff233Sopenharmony_ciint32_t SoftBusGetFileSize(const char *fileName, uint64_t *fileSize);
60060ff233Sopenharmony_cichar *SoftBusRealPath(const char *path, char *absPath);
61060ff233Sopenharmony_ciint32_t SoftBusReadFullFileAndSize(const char *fileName, char *readBuf, uint32_t maxLen, int32_t *size);
62060ff233Sopenharmony_ci
63060ff233Sopenharmony_ci#ifdef __cplusplus
64060ff233Sopenharmony_ci#if __cplusplus
65060ff233Sopenharmony_ci}
66060ff233Sopenharmony_ci#endif /* __cplusplus */
67060ff233Sopenharmony_ci#endif /* __cplusplus */
68060ff233Sopenharmony_ci
69060ff233Sopenharmony_ci#endif // SOFTBUS_ADAPTER_FILE_H