• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# raw_file_manager.h
2
3## Overview
4
5Provides file management functions for the **rawfile** directory. You can use the **ResourceManager** to open a rawfile and perform operations such as data search and reading.
6
7**File to include**: \<rawfile/raw_file_manager.h>
8
9**Library**: librawfile.z.so
10
11**System capability**: SystemCapability.Global.ResourceManager
12
13**Since**: 8
14
15**Related module**: [rawfile](capi-rawfile.md)
16
17## Summary
18
19### Structs
20
21| Name| typedef Keyword| Description                                                                                                                                                                                                  |
22| -- | -- |------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
23| [NativeResourceManager](capi-rawfile-nativeresourcemanager.md) | NativeResourceManager | Represents the native **ResourceManager**. This class encapsulates the native implementation of the JavaScript resource manager. The **ResourceManager** pointer can be obtained by using [OH_ResourceManager_InitNativeResourceManager](#oh_resourcemanager_initnativeresourcemanager).|
24
25### Functions
26
27| Name| Description|
28| -- | -- |
29| [NativeResourceManager *OH_ResourceManager_InitNativeResourceManager(napi_env env, napi_value jsResMgr)](#oh_resourcemanager_initnativeresourcemanager) | Obtains the native **ResourceManager** based on the JavaScript **ResourceManager** to implement rawfile-specific functions.|
30| [void OH_ResourceManager_ReleaseNativeResourceManager(NativeResourceManager *resMgr)](#oh_resourcemanager_releasenativeresourcemanager) | Releases the native **ResourceManager**.|
31| [RawDir *OH_ResourceManager_OpenRawDir(const NativeResourceManager *mgr, const char *dirName)](#oh_resourcemanager_openrawdir) | Traverses all files in the **rawfile** directory.|
32| [RawFile *OH_ResourceManager_OpenRawFile(const NativeResourceManager *mgr, const char *fileName)](#oh_resourcemanager_openrawfile) | Opens a rawfile and reads the data in it.|
33| [RawFile64 *OH_ResourceManager_OpenRawFile64(const NativeResourceManager *mgr, const char *fileName)](#oh_resourcemanager_openrawfile64) | Opens a large rawfile and reads the data in it.|
34| [bool OH_ResourceManager_IsRawDir(const NativeResourceManager *mgr, const char *path)](#oh_resourcemanager_israwdir) | Checks whether the path of a rawfile is a subdirectory in the **rawfile** directory.|
35
36## Function Description
37
38### OH_ResourceManager_InitNativeResourceManager()
39
40```
41NativeResourceManager *OH_ResourceManager_InitNativeResourceManager(napi_env env, napi_value jsResMgr)
42```
43
44**Description**
45
46Obtains the native **ResourceManager** based on the JavaScript **ResourceManager** to implement rawfile-specific functions.
47
48**Since**: 8
49
50
51**Parameters**
52
53| Name| Description|
54| -- | -- |
55| napi_env env | Pointer to the JavaScript Native API (napi) environment.|
56| napi_value jsResMgr | JavaScript **ResourceManager** object.|
57
58**Returns**
59
60| Type                         | Description|
61|-----------------------------| -- |
62| [NativeResourceManager](capi-rawfile-nativeresourcemanager.md) * | Pointer to [NativeResourceManager](capi-rawfile-nativeresourcemanager.md). If the operation fails, a null pointer is returned.|
63
64### OH_ResourceManager_ReleaseNativeResourceManager()
65
66```
67void OH_ResourceManager_ReleaseNativeResourceManager(NativeResourceManager *resMgr)
68```
69
70**Description**
71
72Releases the native **ResourceManager**.
73
74**Since**: 8
75
76
77**Parameters**
78
79| Name| Description|
80| -- | -- |
81| [NativeResourceManager](capi-rawfile-nativeresourcemanager.md) *resMgr | Pointer to [NativeResourceManager](capi-rawfile-nativeresourcemanager.md).|
82
83### OH_ResourceManager_OpenRawDir()
84
85```
86RawDir *OH_ResourceManager_OpenRawDir(const NativeResourceManager *mgr, const char *dirName)
87```
88
89**Description**
90
91Traverses all files in the **rawfile** directory.
92
93**Since**: 8
94
95
96**Parameters**
97
98| Name| Description|
99| -- | -- |
100| const [NativeResourceManager](capi-rawfile-nativeresourcemanager.md) *mgr | Pointer to [NativeResourceManager](capi-rawfile-nativeresourcemanager.md), which is obtained by calling [OH_ResourceManager_InitNativeResourceManager](capi-raw-file-manager-h.md#oh_resourcemanager_initnativeresourcemanager).|
101| const char *dirName | Pointer to the name of the directory to open. If this field is left empty, the root directory will be opened.|
102
103**Returns**
104
105| Type          | Description|
106|--------------| -- |
107| [RawDir](capi-rawfile-rawdir.md) * | Pointer to [RawDir](capi-rawfile-rawdir.md). After using the pointer, call [OH_ResourceManager_CloseRawDir](capi-raw-dir-h.md#oh_resourcemanager_closerawdir) to release it. If the operation fails or **mgr** is empty, a null pointer is returned.|
108
109**Reference**
110
111[OH_ResourceManager_InitNativeResourceManager](capi-raw-file-manager-h.md#oh_resourcemanager_initnativeresourcemanager)
112
113[OH_ResourceManager_CloseRawDir](capi-raw-dir-h.md#oh_resourcemanager_closerawdir)
114### OH_ResourceManager_OpenRawFile()
115
116```
117RawFile *OH_ResourceManager_OpenRawFile(const NativeResourceManager *mgr, const char *fileName)
118```
119
120**Description**
121
122Opens a rawfile and reads the data in it.
123
124**Since**: 8
125
126
127**Parameters**
128
129| Name| Description|
130| -- | -- |
131| const [NativeResourceManager](capi-rawfile-nativeresourcemanager.md) *mgr | Pointer to [NativeResourceManager](capi-rawfile-nativeresourcemanager.md), which is obtained by calling [OH_ResourceManager_InitNativeResourceManager](capi-raw-file-manager-h.md#oh_resourcemanager_initnativeresourcemanager).|
132| const char *fileName | Pointer to the name of the file in the relative path of the **rawfile** root directory.|
133
134**Returns**
135
136| Type| Description|
137| -- | -- |
138| [RawDir](capi-rawfile-rawdir.md) * | Pointer to [RawDir](capi-rawfile-rawdir.md). After using the pointer, call [OH_ResourceManager_CloseRawFile](capi-raw-file-h.md#oh_resourcemanager_closerawfile) to release it. If the operation fails or **mgr** or **fileName** is empty, a null pointer is returned.|
139
140**Reference**
141
142[OH_ResourceManager_InitNativeResourceManager](capi-raw-file-manager-h.md#oh_resourcemanager_initnativeresourcemanager)
143
144[OH_ResourceManager_CloseRawFile](capi-raw-file-h.md#oh_resourcemanager_closerawfile)
145
146### OH_ResourceManager_OpenRawFile64()
147
148```
149RawFile64 *OH_ResourceManager_OpenRawFile64(const NativeResourceManager *mgr, const char *fileName)
150```
151
152**Description**
153
154Opens a large rawfile and reads the data in it.
155
156**Since**: 11
157
158
159**Parameters**
160
161| Name| Description|
162| -- | -- |
163| const [NativeResourceManager](capi-rawfile-nativeresourcemanager.md) *mgr | Pointer to [NativeResourceManager](capi-rawfile-nativeresourcemanager.md), which is obtained by calling [OH_ResourceManager_InitNativeResourceManager](capi-raw-file-manager-h.md#oh_resourcemanager_initnativeresourcemanager).|
164| const char *fileName | Pointer to the name of the file in the relative path of the **rawfile** root directory.|
165
166**Returns**
167
168| Type             | Description|
169|-----------------| -- |
170| [RawFile64](capi-rawfile-rawfile64.md) * | Pointer to [RawFile64](capi-rawfile-rawfile64.md). After using this pointer, call [OH_ResourceManager_CloseRawFile64](capi-raw-file-h.md#oh_resourcemanager_closerawfile64) to release it. If the operation fails or **mgr** or **fileName** is empty, a null pointer is returned.|
171
172**Reference**
173
174[OH_ResourceManager_InitNativeResourceManager](capi-raw-file-manager-h.md#oh_resourcemanager_initnativeresourcemanager)
175
176[OH_ResourceManager_CloseRawFile](capi-raw-file-h.md#oh_resourcemanager_closerawfile)64
177
178### OH_ResourceManager_IsRawDir()
179
180```
181bool OH_ResourceManager_IsRawDir(const NativeResourceManager *mgr, const char *path)
182```
183
184**Description**
185
186Checks whether the path of a raw file is a subdirectory in the **rawfile** directory.
187
188**Since**: 12
189
190
191**Parameters**
192
193| Name| Description|
194| -- | -- |
195| const [NativeResourceManager](capi-rawfile-nativeresourcemanager.md) *mgr | Pointer to [NativeResourceManager](capi-rawfile-nativeresourcemanager.md), which is obtained by calling [OH_ResourceManager_InitNativeResourceManager](capi-raw-file-manager-h.md#oh_resourcemanager_initnativeresourcemanager).|
196| const char *path | Path of a rawfile.|
197
198**Returns**
199
200| Type| Description|
201| -- | -- |
202| bool | **true** if the path is a subdirectory in the **rawfile** directory; **false** otherwise.|
203