• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2023 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  * @syscap SystemCapability.Global.ResourceManager
36  * @library librawfile.z.so
37  * @since 8
38  * @version 1.0
39  */
40 #ifndef GLOBAL_NATIVE_RESOURCE_MANAGER_H
41 #define GLOBAL_NATIVE_RESOURCE_MANAGER_H
42 
43 #include "napi/native_api.h"
44 #include "raw_dir.h"
45 #include "raw_file.h"
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
51 struct NativeResourceManager;
52 
53 /**
54  * @brief Presents the resource manager.
55  *
56  * This class encapsulates the native implementation of the JavaScript resource manager. The pointer to a
57  * <b>ResourceManager</b> object can be obtained by calling {@link OH_ResourceManager_InitNativeResourceManager}.
58  *
59  * @since 8
60  * @version 1.0
61  */
62 typedef struct NativeResourceManager NativeResourceManager;
63 
64 /**
65  * @brief Obtains the native resource manager based on the JavaScipt resource manager.
66  *
67  * You need to obtain the resource manager to process raw files as required.
68  *
69  * @param env Indicates the pointer to the JavaScipt Native Interface (napi) environment.
70  * @param jsResMgr Indicates the JavaScipt resource manager.
71  * @return Returns the pointer to {@link NativeResourceManager}.
72  * @since 8
73  * @version 1.0
74  */
75 NativeResourceManager *OH_ResourceManager_InitNativeResourceManager(napi_env env, napi_value jsResMgr);
76 
77 /**
78  * @brief Releases the native resource manager.
79  *
80  *
81  *
82  * @param resMgr Indicates the pointer to {@link RawDir}.
83  * @since 8
84  * @version 1.0
85  */
86 void OH_ResourceManager_ReleaseNativeResourceManager(NativeResourceManager *resMgr);
87 
88 /**
89  * @brief Opens a raw file directory.
90  *
91  * After it is opened, you can traverse its raw files.
92  *
93  * @param mgr Indicates the pointer to {@link NativeResourceManager} obtained by calling
94  * {@link OH_ResourceManager_InitNativeResourceManager}.
95  * @param dirName Indicates the name of the raw file directory to open. You can pass an empty string to open the
96  * top-level raw file directory.
97  * @return Returns the pointer to {@link RawDir}. After you finish using the pointer, call
98  * {@link OH_ResourceManager_CloseRawDir} to release it.
99  * @see OH_ResourceManager_InitNativeResourceManager
100  * @see OH_ResourceManager_CloseRawDir
101  * @since 8
102  * @version 1.0
103  */
104 RawDir *OH_ResourceManager_OpenRawDir(const NativeResourceManager *mgr, const char *dirName);
105 
106 /**
107  * @brief Opens a raw file.
108  *
109  * After it is opened, you can read its data.
110  *
111  * @param mgr Indicates the pointer to {@link NativeResourceManager} obtained by calling
112  * {@link OH_ResourceManager_InitNativeResourceManager}.
113  * @param fileName Indicates the file path relative to the top-level raw file directory.
114  * @return Returns the pointer to {@link RawFile}. After you finish using the pointer, call
115  * {@link OH_ResourceManager_CloseRawFile} to release it.
116  * @see OH_ResourceManager_InitNativeResourceManager
117  * @see OH_ResourceManager_CloseRawFile
118  * @since 8
119  * @version 1.0
120  */
121 RawFile *OH_ResourceManager_OpenRawFile(const NativeResourceManager *mgr, const char *fileName);
122 
123 /**
124  * @brief Opens a raw file.
125  *
126  * After it is opened, you can read its data.
127  *
128  * @param mgr Indicates the pointer to {@link NativeResourceManager} obtained by calling
129  * {@link OH_ResourceManager_InitNativeResourceManager}.
130  * @param fileName Indicates the file path relative to the top-level raw file directory.
131  * @return Returns the pointer to {@link RawFile64}. After you finish using the pointer, call
132  * {@link OH_ResourceManager_CloseRawFile64} to release it.
133  * @see OH_ResourceManager_InitNativeResourceManager
134  * @see OH_ResourceManager_CloseRawFile64
135  * @since 11
136  * @version 1.0
137  */
138 RawFile64 *OH_ResourceManager_OpenRawFile64(const NativeResourceManager *mgr, const char *fileName);
139 
140 /**
141  * @brief Whether the rawfile resource is a directory or not.
142  *
143  * @param mgr Indicates the pointer to {@link NativeResourceManager} obtained by calling
144  * {@link OH_ResourceManager_InitNativeResourceManager}.
145  * @param path Indicates the rawfile resource relative path.
146  * @return Returns true means the file path is directory, else false.
147  * @since 12
148  * @version 1.0
149  */
150 bool OH_ResourceManager_IsRawDir(const NativeResourceManager *mgr, const char *path);
151 
152 #ifdef __cplusplus
153 };
154 #endif
155 
156 /** @} */
157 #endif // GLOBAL_NATIVE_RESOURCE_MANAGER_H
158