| [RawDir](#rawdir) | Provides the function of accessing rawfile directories. |
| [RawFile](#rawfile) | Provides the function of accessing rawfiles. |
| [NativeResourceManager](#nativeresourcemanager) | Implements the resource manager. |
### Functions
| Name | Description |
| -------- | -------- |
| [OH_ResourceManager_GetRawFileName](#oh_resourcemanager_getrawfilename)([RawDir](#rawdir)\*rawDir, int index) | Obtains the rawfile name via an index. |
| [OH_ResourceManager_GetRawFileCount](#oh_resourcemanager_getrawfilecount)([RawDir](#rawdir)\*rawDir) |Obtains the number of rawfiles in [RawDir](#rawdir). |
| [OH_ResourceManager_CloseRawDir](#oh_resourcemanager_closerawdir)([RawDir](#rawdir)\*rawDir) | Closes an opened [RawDir](#rawdir) and releases all associated resources. |
| [OH_ResourceManager_SeekRawFile](#oh_resourcemanager_seekrawfile)(const[RawFile](#rawfile) \*rawFile, long offset, int whence) |Seeks for the data read/write position in the rawfile based on the specified offset. |
| [OH_ResourceManager_GetRawFileSize](#oh_resourcemanager_getrawfilesize)([RawFile](#rawfile)\*rawFile) | Obtains the length of a rawfile in int32_t. |
| [OH_ResourceManager_CloseRawFile](#oh_resourcemanager_closerawfile)([RawFile](#rawfile)\*rawFile) | Closes an opened [RawFile](#rawfile) and releases all associated resources. |
| [OH_ResourceManager_GetRawFileOffset](#oh_resourcemanager_getrawfileoffset)(const[RawFile](#rawfile) \*rawFile) | Obtains the current offset of the rawfile in int32_t. |
| [OH_ResourceManager_GetRawFileDescriptor](#oh_resourcemanager_getrawfiledescriptor)(const[RawFile](#rawfile) \*rawFile, [RawFileDescriptor](_raw_file_descriptor.md)&descriptor) | Opens a rawfile descriptor. |
| [OH_ResourceManager_ReleaseRawFileDescriptor](#oh_resourcemanager_releaserawfiledescriptor)(const[RawFileDescriptor](_raw_file_descriptor.md) &descriptor) | Closes a rawfile descriptor. |
| [OH_ResourceManager_InitNativeResourceManager](#oh_resourcemanager_initnativeresourcemanager)(napi_env env, napi_value jsResMgr) | Obtains the native resource manager based on JavaScipt resource manager. |
| [OH_ResourceManager_ReleaseNativeResourceManager](#oh_resourcemanager_releasenativeresourcemanager)([NativeResourceManager](#nativeresourcemanager)\*resMgr) | Releases a native resource manager. |
This class encapsulates the native implementation of the JavaScript resource manager. You can obtain the pointer to **ResourceManager** by calling [OH_ResourceManager_InitNativeResourceManager](#oh_resourcemanager_initnativeresourcemanager).
### RawDir
```
typedef struct RawDirRawDir
```
**Description**<br>
Provides the function of accessing rawfile directories.
After the descriptor is opened, you can use it to read the rawfile based on the offset (in int32_t) and file length.
**Parameters**
| Name | Description |
| -------- | -------- |
| rawFile | Indicates the pointer to [RawFile](#rawfile). |
| descriptor | Indicates the rawfile descriptor, and the start position and length of the rawfile file in the HAP package. |
**Returns**
Returns **true** if the rawfile descriptor is opened successfully; returns **false** if the rawfile cannot be accessed.
### OH_ResourceManager_GetRawFileName()
```
const char* OH_ResourceManager_GetRawFileName (RawDir * rawDir, int index )
```
**Description**<br>
Obtains the rawfile name via an index.
You can use this function to traverse a rawfile directory.
**Parameters**
| Name | Description |
| -------- | -------- |
| rawDir | Indicates the pointer to [RawDir](#rawdir). |
| index | Indicates the index of the file in [RawDir](#rawdir). |
**Returns**
Returns the rawfile name via an index. The return value can be used as the input parameter of [OH_ResourceManager_OpenRawFile](#oh_resourcemanager_openrawfile). If no rawfile is found after all rawfiles are traversed, **NULL** will be returned.
After opening a rawfile directory, you can traverse all the rawfile files in it.
**Parameters**
| Name | Description |
| -------- | -------- |
| mgr | Indicates the pointer to [NativeResourceManager](#nativeresourcemanager). You can obtain this pointer by calling [OH_ResourceManager_InitNativeResourceManager](#oh_resourcemanager_initnativeresourcemanager). |
| dirName | Indicates the name of the rawfile directory to open. If this field is left empty, the root directory of rawfile will be opened. |
**Returns**
Returns the pointer to [RawDir](#rawdir). If this pointer is no longer needed after use, call [OH_ResourceManager_CloseRawDir](#oh_resourcemanager_closerawdir) to release it.
After a rawfile is opened, you can read the data in it.
**Parameters**
| Name | Description |
| -------- | -------- |
| mgr | Indicates the pointer to [NativeResourceManager](#nativeresourcemanager). You can obtain this pointer by calling [OH_ResourceManager_InitNativeResourceManager](#oh_resourcemanager_initnativeresourcemanager). |
| fileName | Indicates the file name in the relative path of the rawfile root directory. |
**Returns**
Returns the pointer to [RawFile](#rawfile). If this pointer is no longer needed after use, call [OH_ResourceManager_CloseRawFile](#oh_resourcemanager_closerawfile) to release it.
To prevent file descriptor leakage, you are advised to release a rawfile descriptor after use.
**Parameters**
| Name | Description |
| -------- | -------- |
| descriptor | Indicates the rawfile descriptor, and the start position and length of the rawfile file in the HAP package. |
**Returns**
Returns **true** if the rawfile descriptor is closed successfully; returns **false** otherwise.
### OH_ResourceManager_SeekRawFile()
```
int OH_ResourceManager_SeekRawFile (const RawFile * rawFile, long offset, int whence )
```
**Description**<br>
Seeks for the data read/write position in the rawfile based on the specified offset.
**Parameters**
| Name | Description |
| -------- | -------- |
| rawFile | Indicates the pointer to [RawFile](#rawfile). |
| offset | Indicates the specified offset. |
| whence | Indicates the data read/write position. The options are as follows:<br/>**0**: The read/write position is **offset**.<br/>**1**: The read/write position is the current position plus **offset**.<br/>**2**: The read/write position is the end of the file (EOF) plus **offset**. |
**Returns**
Returns the new data read/write position if the operation is successful; returns **(long) -1** otherwise.