• 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 /**
17  * @addtogroup rawfile
18  * @{
19  *
20  * @brief Provides native functions for the resource manager to operate raw file directories and their raw files.
21  *
22  * You can use the resource manager to traverse, open, seek, read, and close raw files.
23  *
24  * @since 8
25  * @version 1.0
26  */
27 
28 /**
29  * @file raw_file_manager.h
30  *
31  * @brief Declares native functions for the resource manager.
32  *
33  * You can use the resource manager to open raw files for subsequent operations, such as seeking and reading.
34  *
35  * @since 8
36  * @version 1.0
37  */
38 #ifndef GLOBAL_NATIVE_RESOURCE_MANAGER_H
39 #define GLOBAL_NATIVE_RESOURCE_MANAGER_H
40 
41 #include "napi/native_api.h"
42 #include "raw_dir.h"
43 #include "raw_file.h"
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 struct NativeResourceManager;
50 
51 /**
52  * @brief Presents the resource manager.
53  *
54  * This class encapsulates the native implementation of the JavaScript resource manager. The pointer to a
55  * <b>ResourceManager</b> object can be obtained by calling {@link OH_ResourceManager_InitNativeResourceManager}.
56  *
57  * @since 8
58  * @version 1.0
59  */
60 typedef struct NativeResourceManager NativeResourceManager;
61 
62 /**
63  * @brief Obtains the native resource manager based on the JavaScipt resource manager.
64  *
65  * You need to obtain the resource manager to process raw files as required.
66  *
67  * @param env Indicates the pointer to the JavaScipt Native Interface (napi) environment.
68  * @param jsResMgr Indicates the JavaScipt resource manager.
69  * @return Returns the pointer to {@link NativeResourceManager}.
70  * @since 8
71  * @version 1.0
72  */
73 NativeResourceManager *OH_ResourceManager_InitNativeResourceManager(napi_env env, napi_value jsResMgr);
74 
75 /**
76  * @brief Releases the native resource manager.
77  *
78  *
79  *
80  * @param resMgr Indicates the pointer to {@link RawDir}.
81  * @since 8
82  * @version 1.0
83  */
84 void OH_ResourceManager_ReleaseNativeResourceManager(NativeResourceManager *resMgr);
85 
86 /**
87  * @brief Opens a raw file directory.
88  *
89  * After it is opened, you can traverse its raw files.
90  *
91  * @param mgr Indicates the pointer to {@link NativeResourceManager} obtained by calling
92  * {@link OH_ResourceManager_InitNativeResourceManager}.
93  * @param dirName Indicates the name of the raw file directory to open. You can pass an empty string to open the
94  * top-level raw file directory.
95  * @return Returns the pointer to {@link RawDir}. After you finish using the pointer, call
96  * {@link OH_ResourceManager_CloseRawDir} to release it.
97  * @see OH_ResourceManager_InitNativeResourceManager
98  * @see OH_ResourceManager_CloseRawDir
99  * @since 8
100  * @version 1.0
101  */
102 RawDir *OH_ResourceManager_OpenRawDir(const NativeResourceManager *mgr, const char *dirName);
103 
104 /**
105  * @brief Opens a raw file.
106  *
107  * After it is opened, you can read its data.
108  *
109  * @param mgr Indicates the pointer to {@link NativeResourceManager} obtained by calling
110  * {@link OH_ResourceManager_InitNativeResourceManager}.
111  * @param fileName Indicates the file path relative to the top-level raw file directory.
112  * @return Returns the pointer to {@link RawFile}. After you finish using the pointer, call
113  * {@link OH_ResourceManager_CloseRawFile} to release it.
114  * @see OH_ResourceManager_InitNativeResourceManager
115  * @see OH_ResourceManager_CloseRawFile
116  * @since 8
117  * @version 1.0
118  */
119 RawFile *OH_ResourceManager_OpenRawFile(const NativeResourceManager *mgr, const char *fileName);
120 
121 #ifdef __cplusplus
122 };
123 #endif
124 
125 /** @} */
126 #endif // GLOBAL_NATIVE_RESOURCE_MANAGER_H
127