• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *    http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef CM_FILE_OPERATOR_H
17 #define CM_FILE_OPERATOR_H
18 
19 #include "cm_type.h"
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 #define CM_MAX_FILE_NAME_LEN   512
26 #define CM_MAX_DIRENT_FILE_LEN 256
27 
28 struct CmFileDirentInfo {
29     char fileName[CM_MAX_DIRENT_FILE_LEN]; /* point to dirent->d_name */
30 };
31 
32 uint32_t CmFileRead(const char *path, const char *fileName, uint32_t offset, uint8_t *buf, uint32_t len);
33 
34 int32_t CmFileWrite(const char *path, const char *fileName, uint32_t offset, const uint8_t *buf, uint32_t len);
35 
36 int32_t CmFileRemove(const char *path, const char *fileName);
37 
38 uint32_t CmFileSize(const char *path, const char *fileName);
39 
40 int32_t CmIsFileExist(const char *path, const char *fileName);
41 
42 int32_t CmMakeDir(const char *path);
43 
44 void *CmOpenDir(const char *path);
45 
46 int32_t CmCloseDir(void *dirp);
47 
48 int32_t CmGetDirFile(void *dirp, struct CmFileDirentInfo *direntInfo);
49 
50 int32_t CmIsDirExist(const char *path);
51 
52 int32_t CmUserIdLayerGetFileCountAndNames(const char *path, struct CmBlob *fileNames,
53     const uint32_t arraySize, uint32_t *fileCount);
54 
55 int32_t CmUidLayerGetFileCountAndNames(const char *path, struct CmBlob *fileNames,
56     const uint32_t arraySize, uint32_t *fileCount);
57 
58 int32_t CmGetSubDir(void *dirp, struct CmFileDirentInfo *direntInfo);
59 
60 int32_t CmDirRemove(const char *path);
61 
62 #ifdef __cplusplus
63 }
64 #endif
65 
66 #endif /* CM_FILE_OPERATOR_H */
67 
68