• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020-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 SECURITY_APP_FILE_H
17 #define SECURITY_APP_FILE_H
18 
19 #ifdef __cplusplus
20 #if __cplusplus
21 extern "C" {
22 #endif
23 #endif
24 
25 #define FILE_OPEN_FAIL_ERROR_NUM (-1)
26 
27 enum ReadFileErrorCode {
28     DEST_BUFFER_IS_NULL = -1,
29     FILE_IS_CLOSE = -2,
30     MMAP_COPY_FAILED = -3,
31     READ_OFFSET_OUT_OF_RANGE = -4,
32     MMAP_FAILED = -5,
33     MMAP_PARAM_INVALID = -6,
34 };
35 
36 typedef struct {
37     int mmapPosition;
38     int readMoreLen;
39     int mmapSize;
40     char* mapAddr;
41 } MmapInfo;
42 
43 typedef struct {
44     int fp;
45     int offset;
46     int len;
47 } FileRead;
48 
49 int InitVerify(FileRead *file, const char *filePath, int *handle);
50 int HapMMap(int bufCapacity, int offset, MmapInfo *mmapInfo, const FileRead *file);
51 void HapMUnMap(char *mapAddr, int mmapSize);
52 #ifdef __cplusplus
53 #if __cplusplus
54 }
55 #endif
56 #endif
57 
58 #endif
59